当前位置: 首页>>代码示例>>C#>>正文


C# oikonomosEntities.SaveChanges方法代码示例

本文整理汇总了C#中oikonomosEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# oikonomosEntities.SaveChanges方法的具体用法?C# oikonomosEntities.SaveChanges怎么用?C# oikonomosEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oikonomosEntities的用法示例。


在下文中一共展示了oikonomosEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteSite

        public static string DeleteSite(Person currentPerson, int siteId)
        {
            if (currentPerson.HasPermission(Permissions.DeleteSite))
            {
                using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
                {
                    var siteToDelete = (from s in context.Sites
                                        where s.ChurchId == currentPerson.ChurchId
                                        && s.SiteId == siteId
                                        select s).FirstOrDefault();

                    if (siteToDelete == null)
                    {
                        return "Could not delete site";
                    }

                    //Remove all the people linked to this site
                    var peopleLinkedToSite = context.People.Where(p => p.SiteId == siteId);

                    foreach (var p in peopleLinkedToSite)
                    {
                        p.SiteId = null;
                        p.Changed = DateTime.Now;
                    }

                    context.Sites.DeleteObject(siteToDelete);

                    context.SaveChanges();
                    return "Site succesfully removed";
                }
            }
            return "Could not delete site";
        }
开发者ID:petermunnings,项目名称:funwithoiky,代码行数:33,代码来源:ChurchDataAccessor.cs

示例2: AddStandardComment

        public static List<StandardCommentViewModel> AddStandardComment(Person currentPerson, string standardComment)
        {
            using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                if (currentPerson.HasPermission(common.Permissions.AddEvent))
                {
                    var check = CheckToSeeIfTheCommentIsAlreadyThere(currentPerson, standardComment, context);

                    if (check == 0)
                    {
                        var newStandardComment = new StandardComment
                                               {
                                                   StandardComment1= standardComment,
                                                   ChurchId        = currentPerson.ChurchId
                                               };

                        context.StandardComments.AddObject(newStandardComment);
                        context.SaveChanges();
                    }
                }

                return (from e in context.StandardComments
                        where e.ChurchId == currentPerson.ChurchId
                        select new StandardCommentViewModel
                        {
                            StandardCommentId = e.StandardCommentId,
                            StandardComment = e.StandardComment1
                        }).ToList();
            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:30,代码来源:SettingsDataAccessor.cs

示例3: DeletePerson

 public static void DeletePerson(int personId, Person currentPerson)
 {
     if(!currentPerson.HasPermission(Permissions.DeletePerson))
         return;
     using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
     {
         if (RemovePersonFromChurchSpecificTables(personId, currentPerson, context))
         {
             DeletePerson(personId, context);
         }
         context.SaveChanges();
     }
 }
开发者ID:rodown,项目名称:funwithoiky,代码行数:13,代码来源:PersonDataAccessor.cs

示例4: AddPersonToFamily

        public static List<FamilyMemberViewModel> AddPersonToFamily(int familyId, int personId)
        {
            using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                var person = (from p in context.People
                              where p.PersonId == personId
                              select p).First();

                person.FamilyId = familyId;
                person.Changed = DateTime.Now;
                context.SaveChanges();

                return FetchFamilyMembers(personId, familyId, context);
            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:15,代码来源:PersonDataAccessor.cs

示例5: ChangePassword

 public static string ChangePassword(int personId, string currentPassword, string newPassword)
 {
     using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
     {
         var loggedOnPerson = CheckEmailPassword(personId, currentPassword, context);
         if (loggedOnPerson == null)
         {
             return "Invalid Password";
         }
         //Change password
         var passwordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword, "sha1");
         loggedOnPerson.PasswordHash = passwordHash;
         loggedOnPerson.Changed = DateTime.Now;
         context.SaveChanges();
         return "Password succesfully changed";
     }
 }
开发者ID:rodown,项目名称:funwithoiky,代码行数:17,代码来源:PersonDataAccessor.cs

示例6: AddGroupClassification

        public static List<GroupClassificationViewModel> AddGroupClassification(Person currentPerson, string groupClassification)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                if (currentPerson.HasPermission(common.Permissions.AddGroupClassification))
                {//Check to see if it is not already in the db
                    var check = (from g in context.GroupClassifications
                                 where g.ChurchId == currentPerson.ChurchId
                                 && g.Name == groupClassification
                                 select g).Count();
                    if (check == 0)
                    {
                        GroupClassification gc = new GroupClassification();
                        gc.Created = DateTime.Now;
                        gc.Changed = DateTime.Now;
                        gc.Name = groupClassification;
                        gc.ChurchId = currentPerson.ChurchId;
                        if (currentPerson.ChurchId == 3) //ebenezer
                        {
                            gc.GroupTypeId = (int)GroupTypes.LifeGroup;
                        }
                        else
                        {
                            gc.GroupTypeId = (int)GroupTypes.HomeGroup;
                        }

                        context.GroupClassifications.AddObject(gc);
                        context.SaveChanges();
                    }

                }

                return (from g in context.GroupClassifications
                        where g.ChurchId == currentPerson.ChurchId
                        select new GroupClassificationViewModel
                        {
                            GroupClassificationId = g.GroupClassificationId,
                            GroupClassification = g.Name
                        }).ToList();

            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:42,代码来源:SettingsDataAccessor.cs

示例7: AddPermissionsToRole

        public static void AddPermissionsToRole(Person currentPerson, int roleId, List<int> permissionIds)
        {
            if (!currentPerson.HasPermission(Permissions.EditPermissions))
                return;
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                foreach (var permissionId in permissionIds)
                {
                    PermissionRole pr = new PermissionRole()
                    {
                        RoleId = roleId,
                        Changed = DateTime.Now,
                        Created = DateTime.Now,
                        PermissionId = permissionId
                    };

                    context.PermissionRoles.AddObject(pr);
                }

                context.SaveChanges();

            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:23,代码来源:PermissionDataAccessor.cs

示例8: SendEmailAndPassword

        public static bool SendEmailAndPassword(Person currentPerson, int personId, ref string message)
        {
            if (personId == 0)
            {
                message = "You need to save the person before sending the email";
                return false;
            }

            if (!currentPerson.HasPermission(Permissions.SendEmailAndPassword))
            {
                message = "You don't have permission to perform this action";
                return false;
            }

            using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                var church = (from c in context.Churches
                              where c.ChurchId == currentPerson.ChurchId
                              select c).FirstOrDefault();
                if (church == null)
                {
                    message = "Error sending Email";
                    return false;
                }

                var personToUpdate = FetchPerson(personId, context, currentPerson);

                if (personToUpdate == null)
                {
                    message = "Error sending Email";
                    return false;
                }

                if (personToUpdate.HasPermission(Permissions.Login))
                {
                    if (personToUpdate.HasValidEmail())
                    {

                        SendEmailAndPassword(personToUpdate.Firstname,
                            personToUpdate.Family.FamilyName,
                            church,
                            personToUpdate.Email,
                            personToUpdate);

                        context.SaveChanges();
                        message = "Email sent succesfully";
                        return true;
                    }
                    else
                    {
                        message = "Invalid Email address";
                        return false;
                    }
                }
                else
                {
                    var roleName = context.PersonChurches.First(pc => pc.PersonId == personToUpdate.PersonId && pc.ChurchId == personToUpdate.ChurchId).Role.Name;
                    message = string.Format("You cannot send login details to a person with a role of {0}", roleName);
                    return false;
                }
            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:62,代码来源:PersonDataAccessor.cs

示例9: SavePersonRole

 private static void SavePersonRole(oikonomosEntities context, Person personToSave, int roleId)
 {
     var pr = new PersonChurch {RoleId = roleId, ChurchId = personToSave.ChurchId, PersonId = personToSave.PersonId};
     context.AddToPersonChurches(pr);
     context.SaveChanges();
 }
开发者ID:rodown,项目名称:funwithoiky,代码行数:6,代码来源:PersonDataAccessor.cs

示例10: SavePersonFacebookDetails

        public static void SavePersonFacebookDetails(Person person, long facebookId, DateTime? birthday)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                PersonOptionalField facebookOptionalField = new PersonOptionalField();
                facebookOptionalField.PersonId = person.PersonId;
                facebookOptionalField.OptionalFieldId = (int)OptionalFields.Facebook;
                facebookOptionalField.Value = facebookId.ToString();
                facebookOptionalField.Created = DateTime.Now;
                facebookOptionalField.Changed = DateTime.Now;

                context.PersonOptionalFields.AddObject(facebookOptionalField);

                if (birthday != null)
                {
                    var personToUpdate = (from p in context.People
                                  where p.PersonId == person.PersonId
                                  select p).FirstOrDefault();

                    if (personToUpdate.DateOfBirth == null || personToUpdate.DateOfBirth.Value.Year == 1900)
                    {
                        personToUpdate.DateOfBirth = birthday.Value;
                    }
                }

                context.SaveChanges();
            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:28,代码来源:PersonDataAccessor.cs

示例11: SavePersonFacebookId

        public static void SavePersonFacebookId(int personId, string facebookId)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                PersonOptionalField facebookOptionalField = new PersonOptionalField();
                facebookOptionalField.PersonId = personId;
                facebookOptionalField.OptionalFieldId = (int)OptionalFields.Facebook;
                facebookOptionalField.Value = facebookId;
                facebookOptionalField.Created = DateTime.Now;
                facebookOptionalField.Changed = DateTime.Now;

                context.PersonOptionalFields.AddObject(facebookOptionalField);
                context.SaveChanges();
            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:15,代码来源:PersonDataAccessor.cs

示例12: SaveChurchEmailTemplate

 public static void SaveChurchEmailTemplate(Person currentPerson, int churchId, int emailTemplateId, string template)
 {
     using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
     {
         var churchEmailTemplate = context.ChurchEmailTemplates.FirstOrDefault(x => x.ChurchId == churchId && x.EmailTemplateId == emailTemplateId);
         if (churchEmailTemplate == null)
         {
             churchEmailTemplate = new ChurchEmailTemplate {ChurchId = churchId, EmailTemplateId = emailTemplateId};
             context.ChurchEmailTemplates.AddObject(churchEmailTemplate);
         }
         churchEmailTemplate.Template = template;
         context.SaveChanges();
     }
 }
开发者ID:rodown,项目名称:funwithoiky,代码行数:14,代码来源:SettingsDataAccessor.cs

示例13: SavePersonEvents

        public static void SavePersonEvents(PersonEventViewModel personEvents, Person currentPerson)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                if (personEvents != null)
                {
                    foreach (EventViewModel personEvent in personEvents.Events)
                    {
                        if (personEvent.Date == DateTime.MinValue)
                            personEvent.Date = DateTime.Now;
                        var pe = SavePersonEvent(context, personEvents, currentPerson, personEvent);
                        CheckToSeeIfEventAlreadyExists(personEvents, context, personEvent, pe);
                    }

                    context.SaveChanges();
                }
            }
        }
开发者ID:petermunnings,项目名称:funwithoiky,代码行数:18,代码来源:EventDataAccessor.cs

示例14: RemovePermissionsFromRole

        public static void RemovePermissionsFromRole(Person currentPerson, int roleId, List<int> permissionIds)
        {
            if (!currentPerson.HasPermission(Permissions.EditPermissions))
                return;
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                var permissionRoles = (from p in context.PermissionRoles
                                       where p.RoleId == roleId
                                       && permissionIds.Contains(p.PermissionId)
                                       select p).ToList();
                if (permissionRoles != null)
                {
                    foreach (var permissionRole in permissionRoles)
                    {
                        context.DeleteObject(permissionRole);
                    }
                }

                context.SaveChanges();

            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:22,代码来源:PermissionDataAccessor.cs

示例15: DeleteGroupClassification

        public static List<GroupClassificationViewModel> DeleteGroupClassification(Person currentPerson, int groupClassificationId)
        {
            using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
            {
                if (currentPerson.HasPermission(common.Permissions.DeleteGroupClassification))
                {
                    var groups = (from g in context.Groups
                                          where g.ChurchId == currentPerson.ChurchId
                                          && g.GroupClassificationId == groupClassificationId
                                          select g).ToList();

                    foreach (Group g in groups)
                    {
                        g.GroupClassificationId = null;
                    }

                    var groupClassificationsToDelete = (from g in context.GroupClassifications
                                                        where g.ChurchId == currentPerson.ChurchId
                                                        && g.GroupClassificationId == groupClassificationId
                                                        select g).FirstOrDefault();

                    context.GroupClassifications.DeleteObject(groupClassificationsToDelete);

                    context.SaveChanges();

                }

                return (from g in context.GroupClassifications
                        where g.ChurchId == currentPerson.ChurchId
                        select new GroupClassificationViewModel
                        {
                            GroupClassificationId = g.GroupClassificationId,
                            GroupClassification = g.Name
                        }).ToList();

            }
        }
开发者ID:rodown,项目名称:funwithoiky,代码行数:37,代码来源:SettingsDataAccessor.cs


注:本文中的oikonomosEntities.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。