School Commit Init
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.ExtraInfo;
|
||||
using District_3_App.LogIn;
|
||||
using District_3_App.LogIn;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.Entities;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Service;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class CasualProfileService
|
||||
{
|
||||
private SnapshotsService SnapshotsService { get; set; }
|
||||
private ProfileInfoSettings ProfileInfoSettings { get; set; }
|
||||
// private ExtraInfoService extraInfoService { get; set; }
|
||||
public CasualProfileService()
|
||||
{
|
||||
this.SnapshotsService = new SnapshotsService(GetConnectedUserId());
|
||||
this.ProfileInfoSettings = new ProfileInfoSettings(GetConnectedUserId());
|
||||
}
|
||||
public List<MockPost> GetConnectedUserPosts1()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public Guid GetConnectedUserId()
|
||||
{
|
||||
UserManager userManager = new UserManager("./Users.xml");
|
||||
IReadOnlyList<User> users = userManager.GetUsers();
|
||||
foreach (User user in users)
|
||||
{
|
||||
if (userManager.IsUserLoggedIn())
|
||||
{
|
||||
return user.Id;
|
||||
}
|
||||
}
|
||||
return new Guid("11111111-1111-1111-1111-111111111111");
|
||||
}
|
||||
public List<MockPhotoPost> GetConnectedUserPosts()
|
||||
{
|
||||
Guid userId = GetConnectedUserId();
|
||||
List<MockPhotoPost> posts = new List<MockPhotoPost>();
|
||||
string path1 = "/Images/snow.jpg";
|
||||
string path2 = "/Images/peeta.jpeg";
|
||||
string path3 = "/Images/katniss.jpg";
|
||||
string path4 = "/Images/poster.jpeg";
|
||||
|
||||
MockPhotoPost post1 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 1", "Description 1", path1);
|
||||
post1.SetPostId(new Guid("11111111-1111-1111-1111-111111111111"));
|
||||
MockPhotoPost post2 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 2", "Description 2", path2);
|
||||
post2.SetPostId(new Guid("22222222-2222-2222-2222-222222222222"));
|
||||
MockPhotoPost post3 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 3", "Description 3", path3);
|
||||
post3.SetPostId(new Guid("33333333-3333-3333-3333-333333333333"));
|
||||
MockPhotoPost post4 = new MockPhotoPost(userId, new Dictionary<int, List<object>>(), new List<object>(), "Title 4", "Description 4", path4);
|
||||
post4.SetPostId(new Guid("44444444-4444-4444-4444-444444444444"));
|
||||
|
||||
posts.Add(post1);
|
||||
posts.Add(post2);
|
||||
posts.Add(post3);
|
||||
posts.Add(post4);
|
||||
|
||||
return posts;
|
||||
}
|
||||
|
||||
public SnapshotsService GetSnapshotsService()
|
||||
{
|
||||
return SnapshotsService;
|
||||
}
|
||||
public ProfileInfoSettings GetProfileInfoSettings()
|
||||
{
|
||||
return ProfileInfoSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class ProfileInfoSettings
|
||||
{
|
||||
private FancierProfileRepo fancierRepo = new FancierProfileRepo();
|
||||
private Guid profileId;
|
||||
|
||||
public ProfileInfoSettings(Guid profileId)
|
||||
{
|
||||
this.profileId = profileId;
|
||||
}
|
||||
|
||||
public bool AddDailyMotto(string newMotto)
|
||||
{
|
||||
DateTime tomorrow = DateTime.Now.AddDays(1);
|
||||
return fancierRepo.AddDailyMotto(profileId, newMotto, tomorrow);
|
||||
}
|
||||
|
||||
public bool DeleteDailyMotto()
|
||||
{
|
||||
return fancierRepo.DeleteDailyMotto(profileId);
|
||||
}
|
||||
|
||||
public string GetDailyMotto()
|
||||
{
|
||||
return fancierRepo.GetDailyMotto(profileId);
|
||||
}
|
||||
|
||||
public bool AddLink(string newLink)
|
||||
{
|
||||
if (newLink.StartsWith("http://") || newLink.StartsWith("www."))
|
||||
{
|
||||
return fancierRepo.AddLink(profileId, newLink);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteLink(string linkToDelete)
|
||||
{
|
||||
return fancierRepo.DeleteLink(profileId, linkToDelete);
|
||||
}
|
||||
|
||||
public List<string> GetLinks()
|
||||
{
|
||||
return fancierRepo.GetLinks(profileId);
|
||||
}
|
||||
|
||||
public bool SetFrameNumber(int newFrameNumber)
|
||||
{
|
||||
return fancierRepo.SetFrameNumber(profileId, newFrameNumber);
|
||||
}
|
||||
|
||||
public bool DeleteFrameNumber()
|
||||
{
|
||||
return fancierRepo.DeleteFrameNumber(profileId);
|
||||
}
|
||||
|
||||
public int GetFrameNumber()
|
||||
{
|
||||
return fancierRepo.GetFrameNumber(profileId);
|
||||
}
|
||||
|
||||
public bool SetHashtag(string newHashtag)
|
||||
{
|
||||
return fancierRepo.SetHashtag(profileId, newHashtag);
|
||||
}
|
||||
|
||||
public bool DeleteHashtag()
|
||||
{
|
||||
return fancierRepo.DeleteHashtag(profileId);
|
||||
}
|
||||
|
||||
public string GetHashtag()
|
||||
{
|
||||
return fancierRepo.GetHashtag(profileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using District_3_App.Enitities;
|
||||
using District_3_App.Enitities.Mocks;
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App.Service
|
||||
{
|
||||
public class SnapshotsService
|
||||
{
|
||||
private SnapshotsRepo snapshotsRepo;
|
||||
private Guid userId;
|
||||
public SnapshotsService(Guid currentUserId)
|
||||
{
|
||||
this.snapshotsRepo = new SnapshotsRepo(currentUserId);
|
||||
this.userId = currentUserId;
|
||||
}
|
||||
|
||||
public bool AddHighlight(string newHighlightName, string newHighlightCover, List<Guid> guids)
|
||||
{
|
||||
HighlightsRepo repo = snapshotsRepo.GetHighlightsRepo();
|
||||
// aici ar trebui apelat din post repository
|
||||
Highlight h = new Highlight(newHighlightName, newHighlightCover);
|
||||
|
||||
if (newHighlightName == null)
|
||||
{
|
||||
newHighlightName = "Highlight_" + h.GetHighlightId().ToString().Replace("-", "_");
|
||||
h.SetName(newHighlightName);
|
||||
}
|
||||
|
||||
int rnd = new Random().Next(0, guids.Count());
|
||||
if (guids.Count == 0)
|
||||
{
|
||||
newHighlightCover = "../Images/black.png";
|
||||
}
|
||||
while (newHighlightCover == null)
|
||||
{
|
||||
foreach (MockPhotoPost photoPost in repo.GetConnectedUserPosts(new Guid()))
|
||||
{
|
||||
if (photoPost != null)
|
||||
{
|
||||
if (photoPost.GetPostId().Equals(guids[rnd]))
|
||||
{
|
||||
newHighlightCover = photoPost.GetPhoto();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
snapshotsRepo.AddHighlight(h);
|
||||
|
||||
foreach (Guid postId in guids)
|
||||
{
|
||||
repo.AddPostToHighlight(this.userId, postId, h.GetHighlightId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool RemoveHighlight(Highlight highlight)
|
||||
{
|
||||
return snapshotsRepo.RemoveHighlight(highlight);
|
||||
}
|
||||
public bool AddPostToHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return snapshotsRepo.AddPostToHighlight(postId, highlightId);
|
||||
}
|
||||
public bool RemovePostFromHighlight(Guid highlightId, Guid postId)
|
||||
{
|
||||
return snapshotsRepo.RemovePostFromHighlight(postId, highlightId);
|
||||
}
|
||||
public List<Highlight> GetHighlightsOfUser()
|
||||
{
|
||||
return snapshotsRepo.GetHighlightsOfUser();
|
||||
}
|
||||
public Highlight GetHighlight(Guid highlightId)
|
||||
{
|
||||
return snapshotsRepo.GetHighlight(highlightId);
|
||||
}
|
||||
|
||||
public List<MockPhotoPost> GetPostsOfHighlight(Guid highlightId)
|
||||
{
|
||||
return snapshotsRepo.GetPostsOfHighlight(highlightId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user