private static void CreateDummyUsers(int NumOfUsers) { Role lDummyRole = new Role() { Name = "User" }; using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { if (lContainer.Users.Count() > NumOfUsers + 1) { return; } } for (int i = 0; i < NumOfUsers; i++ ) { User pUser = new User() { Name = lDummyRole.Name + i.ToString(), LoginCredential = new LoginCredential() { UserName = lDummyRole.Name + i.ToString(), Password = "******" }, Email = lDummyRole.Name + i.ToString() + "@Dummy.com", Address = "1 Central Park" }; pUser.Roles.Add(lDummyRole); ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(pUser); } }
public List<Recommendation> GetRecommendationListByUserId(int UserId) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.ContextOptions.LazyLoadingEnabled = false; List<Recommendation> Result = new List<Recommendation>(); var pUser = lContainer.Users.Include("Medium").FirstOrDefault(lUser => lUser.Id == UserId); //get the media list of this user List<Media> pMediaOfUser = pUser.Medium.ToList(); foreach (Media pMedia in pMediaOfUser) { Recommendation pRecommendation = lContainer.Recommendations.Include("MostLikeMatching").FirstOrDefault(lRecommendation => lRecommendation.Medium.Id == pMedia.Id); if( pRecommendation != null ){ //for every media, find the binded recommendation and find the most frequent LikeMatching binded to it LikeMatching tLikeMatching = pRecommendation.MostLikeMatching; if (tLikeMatching != null) { pRecommendation.MostLikeMatching = lContainer.LikeMatchings.Include("Medium") .Where(lLikeMatching => lLikeMatching.Id == tLikeMatching.Id) .FirstOrDefault(); //add the media binded with this LikeMatching to the Media List if (tLikeMatching != null && tLikeMatching.Medium != null) { Result.Add(pRecommendation); } tLikeMatching = null; } } } return this.RipResultList(Result, pMediaOfUser); } }
public LikeMatching GetMostFrequentLikeMatchingByRecommendation(Recommendation pRecommendation) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return pRecommendation.MostLikeMatching; } }
public List<LikeMatching> GetLikeMatchingsByRecommendation(Recommendation pRecommendation) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return pRecommendation.LikeMatchings.ToList(); } }
private Order RetrieveDeliveryOrderByOrderNumber(Guid pOrderNumber) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return lContainer.Orders.Include("Customer").Where((aOrder) => aOrder.OrderNumber == pOrderNumber).FirstOrDefault(); } }
public LikeMatching GetLikeMatchingById(int Id) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { LikeMatching pLikeMatching = lContainer.LikeMatchings.Where((tLikeMatching) => tLikeMatching.Id == Id).FirstOrDefault(); return pLikeMatching; } }
private Order RetrieveDeliveryOrderDeliveryId(Guid pDeliveryId) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { Delivery lDelivery = lContainer.Deliveries.Include("Order.Customer").Where((pDel) => pDel.ExternalDeliveryIdentifier == pDeliveryId).FirstOrDefault(); return lDelivery.Order; } }
public Recommendation GetRecommendationByMedia(Media pMedia) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { Recommendation recommendation = lContainer.Recommendations.Where((pRecommendation) => pRecommendation.Medium.Id == pMedia.Id).FirstOrDefault(); return recommendation; } }
public Recommendation GetRecommendationById(int Id) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { Recommendation recommendation = lContainer.Recommendations.Where((pRecommendation) => pRecommendation.Id == Id).FirstOrDefault(); return recommendation; } }
public User ReadUserById(int pUserId) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { User lCustomer = lContainer.Users.Where((pUser) => pUser.Id == pUserId).FirstOrDefault(); return lCustomer; } }
public Media GetMediaById(int pId) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return (from MediaItem in lContainer.Media where MediaItem.Id == pId select MediaItem).FirstOrDefault(); } }
public List<Entities.Media> GetMediaItems(int pOffset, int pCount) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return (from MediaItem in lContainer.Media.Include(Common.ReflectionUtil.GetPropertyName(() => new Media().Stocks)) orderby MediaItem.Id select MediaItem).Skip(pOffset).Take(pCount).ToList(); } }
public Media GetMediaById(int pId) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return (from MediaItem in lContainer.Media.Include(Common.ReflectionUtil.GetPropertyName(() => new Media().Stocks)) where MediaItem.Id == pId select MediaItem).FirstOrDefault(); } }
public List<Entities.Media> GetMediaItems(int pOffset, int pCount) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return (from MediaItem in lContainer.Media orderby MediaItem.Id select MediaItem).Skip(pOffset).Take(pCount).ToList(); } }
public void DeleteUser(User pUser) { using(TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.Users.DeleteObject(pUser); lContainer.SaveChanges(); } }
public List<Role> GetRolesForUserName(string pUserName) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.ContextOptions.LazyLoadingEnabled = false; var lUser = lContainer.Users.Include("Roles").FirstOrDefault((pUser) => pUser.LoginCredential.UserName == pUserName); return lUser.Roles.ToList(); } }
public Media GetMediaByUPC(String pUPC) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { return (from MediaItem in lContainer.Medias where MediaItem.UPC == pUPC select MediaItem).FirstOrDefault(); } }
public void SubmitOrder(Entities.Order pOrder) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.Orders.ApplyChanges(pOrder); lContainer.SaveChanges(); lScope.Complete(); } }
public void DeleteRecommendation(Recommendation pRecommendation) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.Recommendations.DeleteObject(pRecommendation); lContainer.SaveChanges(); lScope.Complete(); } }
public void CreateUser(VideoStore.Business.Entities.User pUser) { using(TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.Users.AddObject(pUser); lContainer.SaveChanges(); lScope.Complete(); } }
public void DeleteLikeMatching(LikeMatching pLikeMatching) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.LikeMatchings.DeleteObject(pLikeMatching); lContainer.SaveChanges(); lScope.Complete(); } }
public void UpdateLikeMatching(LikeMatching pLikeMatching) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { lContainer.LikeMatchings.Attach(pLikeMatching); lContainer.ObjectStateManager.ChangeObjectState(pLikeMatching, System.Data.EntityState.Modified); lContainer.SaveChanges(); lScope.Complete(); } }
public List<Media> GetMediumUserLikes(int pUserId) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { User pUser = lContainer.Users.Include("Medium").Where((tUser) => tUser.Id == pUserId).FirstOrDefault(); lScope.Complete(); return pUser.Medium.ToList(); } }
public bool ValidateUserCredentials(string username, string password) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { string lHashedPassword = global::Common.Cryptography.sha512encrypt(password); var lCredentials = from lCredential in lContainer.LoginCredentials where lCredential.UserName == username && lCredential.EncryptedPassword == lHashedPassword select lCredential; return lCredentials.Count() > 0; } }
private void UpdateDeliveryStatus(Guid pDeliveryId, DeliveryStatus status) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { Delivery lDelivery = lContainer.Deliveries.Where((pDel) => pDel.ExternalDeliveryIdentifier == pDeliveryId).FirstOrDefault(); if (lDelivery != null) { lDelivery.DeliveryStatus = status; lContainer.SaveChanges(); } lScope.Complete(); } }
private static void CreateUser() { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { if (lContainer.Users.Where((pUser) => pUser.Name == "Customer").Count() > 0) return; } User lCustomer = new User() { Name = "Customer", LoginCredential = new LoginCredential() { UserName = "******", Password = "******" }, Email = "*****@*****.**", Address = "1 Central Park", BankAccountNumber = 456, }; ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(lCustomer); }
public void CancelOrder(Entities.Order pOrder) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { try { pOrder.RevertStockLevels(); lContainer.Orders.ApplyChanges(pOrder); SendOrderDeclinedEmail(pOrder); lContainer.SaveChanges(); lScope.Complete(); } catch (Exception lException) { SendOrderErrorMessage(pOrder, lException); throw; } } }
public User ReadUserByName(string pUserName) { using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { var lCredentials = from lCredential in lContainer.LoginCredentials where lCredential.UserName == pUserName select lCredential; if (lCredentials.Count() > 0) { LoginCredential lCredential = lCredentials.First(); var lUsers = from lCustomer in lContainer.Users where lCustomer.LoginCredential.Id == lCredential.Id select lCustomer; if (lUsers.Count() > 0) { return lUsers.First(); } } return null; } }
private static void CreateOperator() { Role lOperatorRole = new Role() { Name = "Operator" }; using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { if (lContainer.Roles.Count() > 0) { return; } } User lOperator = new User() { Name = "Operator", LoginCredential = new LoginCredential() { UserName = "******", Password = "******" }, Email = "*****@*****.**", Address = "1 Central Park" }; lOperator.Roles.Add(lOperatorRole); ServiceLocator.Current.GetInstance<IUserProvider>().CreateUser(lOperator); }
public void SubmitDelivery(Entities.Order pOrder) { using (TransactionScope lScope = new TransactionScope()) using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer()) { try { PlaceDeliveryForOrder(pOrder); lContainer.Orders.ApplyChanges(pOrder); SendOrderPlacedConfirmation(pOrder); lContainer.SaveChanges(); lScope.Complete(); } catch (Exception lException) { SendOrderErrorMessage(pOrder, lException); throw; } } }