public static bool DeleteUserProfile(long userId) { using (var context = new BackofficeUnitOfWork()) { Profile profile = context.Profile.Get(userId); context.Notification.Delete(i => i.ToUserID == profile.ID_User); context.Notification.Delete(i => i.FromUserID == profile.ID_User); context.ProfileSettings.Delete(i => i.ID_Profile == profile.ID); context.Payment.Delete(i => i.ID_Profile == profile.ID); context.PostHidden.Delete(i => i.ID_User == profile.ID_User); context.PostComment.Delete(i => i.ID_User == profile.ID_User); //context.PostCommentLike.Delete(i => i.ID_User == profile.ID_User); context.PostLike.Delete(i => i.ID_User == profile.ID_User); context.Post.Delete(i => i.ID_User == profile.ID_User); context.Friend.Delete(i => i.ID_User == profile.ID_User); context.Friend.Delete(i => i.ID_User_Friend == profile.ID_User); context.AspNetUsers.Delete(profile.ID_User); context.Profile.Delete(userId); context.Save(); return(true); } }
public static long CreateDefaultProfile(Profile profile) { using (var context = new BackofficeUnitOfWork()) { profile.Active = false; profile.CreateDate = DateTime.Now; profile.LastChangeDate = DateTime.Now; profile.ProfileSettings.Add(new ProfileSettings() { Active = true, CreateDate = profile.CreateDate, LastChangeDate = profile.LastChangeDate, ShowSocialNetworks = true, ShowBirthDate = true, ShowContactInformation = true, ShowDisplayName = true, LikesOnYourPosts = true, CommentsOnYourPosts = true, ReceiveNotificationsByEmail = true }); context.Profile.Create(profile); //AspNetUsers user = context.AspNetUsers.Get(profile.ID_User); //user.AspNetRoles.Add(RoleRepository.GetRole(context, InsuranceSocialNetworkCore.Enums.RoleEnum.USER)); context.Save(); return(profile.ID); } }
public static long CreatePost(Post post) { using (var context = new BackofficeUnitOfWork()) { post.Active = true; post.CreateDate = DateTime.Now; context.Post.Create(post); context.Save(); //using (var transaction = new TransactionScope()) //{ // context.Post.Create(post); // context.Save(); // if(null != post.PostImage && post.PostImage.Count > 0) // { // } // transaction.Complete(); //} return(post.ID); } }
public static bool DeletePostAsAdmin(long postId) { using (var context = new BackofficeUnitOfWork()) { Post post = context.Post .Fetch() .Where(i => i.ID == postId) .FirstOrDefault(); if (null == post) { return(false); } context.PostComment.Delete(i => i.ID_Post == post.ID); context.PostHidden.Delete(i => i.ID_Post == post.ID); context.PostImage.Delete(i => i.ID_Post == post.ID); context.PostLike.Delete(i => i.ID_Post == post.ID); context.Notification.Delete(i => i.ID_Post == post.ID); context.Post.Delete(post.ID); context.Save(); return(true); } }
public static bool MarkNotificationsAsRead(string id) { using (var context = new BackofficeUnitOfWork()) { //IQueryable<Notification> query = context.Notification List <Notification> items = context.Notification .Fetch() .Where(i => i.ToUserID == id && !i.Read) .ToList(); if (null == items || items.Count == 0) { return(false); } foreach (Notification item in items) { item.Read = true; item.ReadDate = DateTime.Now; context.Notification.Update(item); } context.Save(); return(true); } }
public static bool UpdateEmailAuthorizedForAutomaticApproval(string userId, string[] emailPatterns) { using (var context = new BackofficeUnitOfWork()) { context.AuthorizedEmail.Delete(i => i.ID_User == userId); if (null != emailPatterns && emailPatterns.Length > 0) { foreach (string emailPattern in emailPatterns) { context.AuthorizedEmail.Create(new AuthorizedEmail() { ID_User = userId, Active = true, Email = emailPattern.ToLower(), CreateDate = DateTime.Now, LastChangeDate = DateTime.Now }); } } context.Save(); return(true); } }
public static bool UpdateCompaniesWorkingWith(string userId, long[] companiesIds, CompanyTypeEnum type) { using (var context = new BackofficeUnitOfWork()) { context.CompanyWorkingWith.Delete(i => i.ID_User == userId); if (null != companiesIds && companiesIds.Length > 0) { var companyType = GetCompanyType(type); int index = 0; foreach (long companyId in companiesIds) { context.CompanyWorkingWith.Create(new CompanyWorkingWith() { ID_User = userId, Active = true, ID_Company = companyId, ID_CompanyType = companyType.ID, Order = index, CreateDate = DateTime.Now, LastChangeDate = DateTime.Now }); ++index; } } context.Save(); return(true); } }
public static bool AcceptFriendRequest(string userId, string newFriendId) { using (var context = new BackofficeUnitOfWork()) { long requestAcceptedStatusId = context.FriendStatus.Fetch().FirstOrDefault(j => j.Token == "REQUEST_ACCEPTED").ID; Friend friendItem = context.Friend .Fetch() .FirstOrDefault(i => i.AspNetUsers.Id == userId && i.AspNetUsers1.Id == newFriendId || i.AspNetUsers1.Id == userId && i.AspNetUsers.Id == newFriendId); if (null == friendItem) { return(false); } friendItem.ID_FriendStatus = requestAcceptedStatusId; friendItem.LastChangeDate = DateTime.Now; context.Friend.Update(friendItem); context.Save(); return(true); } }
public static long CreatePaymentNotification(PaymentNotification paymentNotification) { using (var context = new BackofficeUnitOfWork()) { context.PaymentNotification.Create(paymentNotification); context.Save(); return(paymentNotification.ID); } }
public static bool UpdateUserProfileSettings(ProfileSettings profileSettings) { using (var context = new BackofficeUnitOfWork()) { profileSettings.LastChangeDate = DateTime.Now; context.ProfileSettings.Update(profileSettings); context.Save(); return(true); } }
public static bool EditPaymentNotification(PaymentNotification paymentNotification) { using (var context = new BackofficeUnitOfWork()) { paymentNotification.LastChangeDate = DateTime.Now; context.PaymentNotification.Update(paymentNotification); context.Save(); return(true); } }
public static ChatNote CreateNote(ChatNote note) { using (var context = new BackofficeUnitOfWork()) { note.CreateDate = note.LastUpdateDate = DateTime.Now; context.ChatNote.Create(note); context.Save(); return(note); } }
public static bool EditBanner(Banner banner) { using (var context = new BackofficeUnitOfWork()) { banner.LastChangeDate = DateTime.Now; context.Banner.Update(banner); context.Save(); return(true); } }
public static bool EditGarage(Garage garage) { using (var context = new BackofficeUnitOfWork()) { Garage item = GetGarage(garage.ID); item.LastChangeDate = DateTime.Now; item.Address = garage.Address; item.ContactEmail = garage.ContactEmail; item.Description = garage.Description; item.Address = garage.Address; item.PostalCode = garage.PostalCode; item.ID_District = garage.ID_District; item.ID_County = garage.ID_County; item.ID_Parish = garage.ID_Parish; item.SameInformationForInvoice = garage.SameInformationForInvoice; item.Address = garage.Address; item.PostalCode = garage.PostalCode; item.Invoice_ID_District = garage.Invoice_ID_District; item.Invoice_ID_County = garage.Invoice_ID_County; item.Invoice_ID_Parish = garage.Invoice_ID_Parish; item.ID_Service = garage.ID_Service; item.MobilePhone_1 = garage.MobilePhone_1; item.MobilePhone_2 = garage.MobilePhone_2; item.Fax = garage.Fax; item.Name = garage.Name; item.BusinessName = garage.BusinessName; item.NIF = garage.NIF; item.OfficialAgent = garage.OfficialAgent; item.OfficialPartner = garage.OfficialPartner; item.Telephone_1 = garage.Telephone_1; item.Telephone_2 = garage.Telephone_2; item.Website = garage.Website; item.LogoPhoto = null != garage.LogoPhoto ? garage.LogoPhoto : item.LogoPhoto; item.LibaxEntityID = garage.LibaxEntityID; if (null == item.Payment && null != garage.Payment) { item.Payment = garage.Payment; context.Payment.Create(garage.Payment.Last()); } else if (null != item.Payment && null != garage.Payment && item.Payment.Count != garage.Payment.Count) { item.Payment.Add(garage.Payment.Last()); context.Payment.Create(garage.Payment.Last()); } context.Garage.Update(item); context.Save(); return(true); } }
public static long CreateConstructionCompany(ConstructionCompany constructionCompany) { using (var context = new BackofficeUnitOfWork()) { constructionCompany.Active = true; constructionCompany.CreateDate = constructionCompany.LastChangeDate = DateTime.Now; context.ConstructionCompany.Create(constructionCompany); context.Save(); return(constructionCompany.ID); } }
public static long CreateHomeApplianceRepair(HomeApplianceRepair homeApplianceRepair) { using (var context = new BackofficeUnitOfWork()) { homeApplianceRepair.Active = true; homeApplianceRepair.CreateDate = homeApplianceRepair.LastChangeDate = DateTime.Now; context.HomeApplianceRepair.Create(homeApplianceRepair); context.Save(); return(homeApplianceRepair.ID); } }
public static long CreatePayment(Payment payment) { using (var context = new BackofficeUnitOfWork()) { payment.CreateDate = DateTime.Now; payment.LastChangeDate = DateTime.Now; context.Payment.Create(payment); context.Save(); return(payment.ID); } }
public static bool CreateBanner(Banner banner) { using (var context = new BackofficeUnitOfWork()) { banner.Active = true; banner.CreateDate = banner.LastChangeDate = DateTime.Now; context.Banner.Create(banner); context.Save(); return(banner.ID > 0); } }
public static long CreateGarage(Garage garage) { using (var context = new BackofficeUnitOfWork()) { garage.Active = true; garage.CreateDate = garage.LastChangeDate = DateTime.Now; context.Garage.Create(garage); context.Save(); return(garage.ID); } }
public static long CreateInsuranceCompanyContact(InsuranceCompanyContact insuranceCompanyContact) { using (var context = new BackofficeUnitOfWork()) { insuranceCompanyContact.Active = true; insuranceCompanyContact.CreateDate = insuranceCompanyContact.LastChangeDate = DateTime.Now; context.InsuranceCompanyContact.Create(insuranceCompanyContact); context.Save(); return(insuranceCompanyContact.ID); } }
public static long CreateMedicalClinic(MedicalClinic medicalClinic) { using (var context = new BackofficeUnitOfWork()) { medicalClinic.Active = true; medicalClinic.CreateDate = medicalClinic.LastChangeDate = DateTime.Now; context.MedicalClinic.Create(medicalClinic); context.Save(); return(medicalClinic.ID); } }
public static long CreateComment(PostComment comment) { using (var context = new BackofficeUnitOfWork()) { comment.Active = true; comment.Date = DateTime.Now; context.PostComment.Create(comment); context.Save(); return(comment.ID); } }
public static bool DeactivateConstructionCompany(long id) { using (var context = new BackofficeUnitOfWork()) { ConstructionCompany constructionCompany = context.ConstructionCompany.Get(id); constructionCompany.Active = false; constructionCompany.LastChangeDate = DateTime.Now; context.Save(); return(true); } }
public static bool EditHomeApplianceRepair(HomeApplianceRepair homeApplianceRepair) { using (var context = new BackofficeUnitOfWork()) { HomeApplianceRepair item = context.HomeApplianceRepair.Get(homeApplianceRepair.ID); item.LastChangeDate = DateTime.Now; item.Address = homeApplianceRepair.Address; item.ContactEmail = homeApplianceRepair.ContactEmail; item.Description = homeApplianceRepair.Description; item.Address = homeApplianceRepair.Address; item.PostalCode = homeApplianceRepair.PostalCode; item.ID_District = homeApplianceRepair.ID_District; item.ID_County = homeApplianceRepair.ID_County; item.ID_Parish = homeApplianceRepair.ID_Parish; item.SameInformationForInvoice = homeApplianceRepair.SameInformationForInvoice; item.Address = homeApplianceRepair.Address; item.PostalCode = homeApplianceRepair.PostalCode; item.Invoice_ID_District = homeApplianceRepair.Invoice_ID_District; item.Invoice_ID_County = homeApplianceRepair.Invoice_ID_County; item.Invoice_ID_Parish = homeApplianceRepair.Invoice_ID_Parish; item.ID_Service = homeApplianceRepair.ID_Service; item.MobilePhone_1 = homeApplianceRepair.MobilePhone_1; item.MobilePhone_2 = homeApplianceRepair.MobilePhone_2; item.Fax = homeApplianceRepair.Fax; item.Name = homeApplianceRepair.Name; item.BusinessName = homeApplianceRepair.BusinessName; item.NIF = homeApplianceRepair.NIF; item.OfficialAgent = homeApplianceRepair.OfficialAgent; item.OfficialPartner = homeApplianceRepair.OfficialPartner; item.Telephone_1 = homeApplianceRepair.Telephone_1; item.Telephone_2 = homeApplianceRepair.Telephone_2; item.Website = homeApplianceRepair.Website; item.LogoPhoto = null != homeApplianceRepair.LogoPhoto ? homeApplianceRepair.LogoPhoto : item.LogoPhoto; item.LibaxEntityID = homeApplianceRepair.LibaxEntityID; if (null == item.Payment && null != homeApplianceRepair.Payment) { item.Payment = homeApplianceRepair.Payment; } else if (null != item.Payment && null != homeApplianceRepair.Payment && item.Payment.Count != homeApplianceRepair.Payment.Count) { item.Payment.Add(homeApplianceRepair.Payment.Last()); } context.HomeApplianceRepair.Update(item); context.Save(); return(true); } }
public static bool DeactivateHomeApplianceRepair(long id) { using (var context = new BackofficeUnitOfWork()) { HomeApplianceRepair homeApplianceRepair = context.HomeApplianceRepair.Get(id); homeApplianceRepair.Active = false; homeApplianceRepair.LastChangeDate = DateTime.Now; context.Save(); return(true); } }
public static bool EditInsuranceCompanyContact(InsuranceCompanyContact insuranceCompanyContact) { using (var context = new BackofficeUnitOfWork()) { InsuranceCompanyContact item = context.InsuranceCompanyContact.Get(insuranceCompanyContact.ID); item.LastChangeDate = DateTime.Now; item.Address = insuranceCompanyContact.Address; item.ContactEmail = insuranceCompanyContact.ContactEmail; item.Description = insuranceCompanyContact.Description; item.Address = insuranceCompanyContact.Address; item.PostalCode = insuranceCompanyContact.PostalCode; item.ID_District = insuranceCompanyContact.ID_District; item.ID_County = insuranceCompanyContact.ID_County; item.ID_Parish = insuranceCompanyContact.ID_Parish; item.SameInformationForInvoice = insuranceCompanyContact.SameInformationForInvoice; item.Address = insuranceCompanyContact.Address; item.PostalCode = insuranceCompanyContact.PostalCode; item.Invoice_ID_District = insuranceCompanyContact.Invoice_ID_District; item.Invoice_ID_County = insuranceCompanyContact.Invoice_ID_County; item.Invoice_ID_Parish = insuranceCompanyContact.Invoice_ID_Parish; item.ID_Service = insuranceCompanyContact.ID_Service; item.MobilePhone_1 = insuranceCompanyContact.MobilePhone_1; item.MobilePhone_2 = insuranceCompanyContact.MobilePhone_2; item.Fax = insuranceCompanyContact.Fax; item.Name = insuranceCompanyContact.Name; item.BusinessName = insuranceCompanyContact.BusinessName; item.NIF = insuranceCompanyContact.NIF; item.OfficialAgent = insuranceCompanyContact.OfficialAgent; item.OfficialPartner = insuranceCompanyContact.OfficialPartner; item.Telephone_1 = insuranceCompanyContact.Telephone_1; item.Telephone_2 = insuranceCompanyContact.Telephone_2; item.Website = insuranceCompanyContact.Website; item.LogoPhoto = null != insuranceCompanyContact.LogoPhoto ? insuranceCompanyContact.LogoPhoto : item.LogoPhoto; item.LibaxEntityID = insuranceCompanyContact.LibaxEntityID; if (null == item.Payment && null != insuranceCompanyContact.Payment) { item.Payment = insuranceCompanyContact.Payment; } else if (null != item.Payment && null != insuranceCompanyContact.Payment && item.Payment.Count != insuranceCompanyContact.Payment.Count) { item.Payment.Add(insuranceCompanyContact.Payment.Last()); } context.InsuranceCompanyContact.Update(item); context.Save(); return(true); } }
public static bool DeactivateInsuranceCompanyContact(long id) { using (var context = new BackofficeUnitOfWork()) { InsuranceCompanyContact insuranceCompanyContact = context.InsuranceCompanyContact.Get(id); insuranceCompanyContact.Active = false; insuranceCompanyContact.LastChangeDate = DateTime.Now; context.Save(); return(true); } }
public static bool EditConstructionCompany(ConstructionCompany constructionCompany) { using (var context = new BackofficeUnitOfWork()) { ConstructionCompany item = context.ConstructionCompany.Get(constructionCompany.ID); item.LastChangeDate = DateTime.Now; item.Address = constructionCompany.Address; item.ContactEmail = constructionCompany.ContactEmail; item.Description = constructionCompany.Description; item.Address = constructionCompany.Address; item.PostalCode = constructionCompany.PostalCode; item.ID_District = constructionCompany.ID_District; item.ID_County = constructionCompany.ID_County; item.ID_Parish = constructionCompany.ID_Parish; item.SameInformationForInvoice = constructionCompany.SameInformationForInvoice; item.Address = constructionCompany.Address; item.PostalCode = constructionCompany.PostalCode; item.Invoice_ID_District = constructionCompany.Invoice_ID_District; item.Invoice_ID_County = constructionCompany.Invoice_ID_County; item.Invoice_ID_Parish = constructionCompany.Invoice_ID_Parish; item.ID_Service = constructionCompany.ID_Service; item.MobilePhone_1 = constructionCompany.MobilePhone_1; item.MobilePhone_2 = constructionCompany.MobilePhone_2; item.Fax = constructionCompany.Fax; item.Name = constructionCompany.Name; item.BusinessName = constructionCompany.BusinessName; item.NIF = constructionCompany.NIF; item.OfficialAgent = constructionCompany.OfficialAgent; item.OfficialPartner = constructionCompany.OfficialPartner; item.Telephone_1 = constructionCompany.Telephone_1; item.Telephone_2 = constructionCompany.Telephone_2; item.Website = constructionCompany.Website; item.LogoPhoto = null != constructionCompany.LogoPhoto ? constructionCompany.LogoPhoto : item.LogoPhoto; item.LibaxEntityID = constructionCompany.LibaxEntityID; if (null == item.Payment && null != constructionCompany.Payment) { item.Payment = constructionCompany.Payment; } else if (null != item.Payment && null != constructionCompany.Payment && item.Payment.Count != constructionCompany.Payment.Count) { item.Payment.Add(constructionCompany.Payment.Last()); } context.ConstructionCompany.Update(item); context.Save(); return(true); } }
public static bool DeleteBanner(long id) { using (var context = new BackofficeUnitOfWork()) { Banner item = context.Banner.Get(id); item.DeleteDate = DateTime.Now; item.Active = false; context.Banner.Update(item); context.Save(); return(true); } }
public static bool ActivateUser(string userId) { using (var context = new BackofficeUnitOfWork()) { AspNetUsers user = context.AspNetUsers.Get(userId); user.LockoutEndDateUtc = null; context.AspNetUsers.Update(user); context.Save(); return(true); } }