Beispiel #1
0
        public PersonResponse PersonEdit(EH_Person person_)
        {
            PersonResponse personResponse = new PersonResponse();

            using (EHContext context = new EHContext())
            {
                using (DbContextTransaction contextTransaction = context.Database.BeginTransaction())
                {
                    EH_Person person = context.EH_Person.Where(p => p.PersonId == person_.PersonId && p.Deleted == false).FirstOrDefault();
                    person.PersonName   = person_.PersonName;
                    person.PersonMailID = person_.PersonMailID;
                    person.UserName     = person_.UserName;
                    person.Password     = person_.Password;
                    person.Enabled      = person_.Enabled;
                    context.SaveChanges();

                    EH_PersonRoleMapping personRoleMapping = context.EH_PersonRoleMapping.Where(prm => prm.PersonId == person_.PersonId).FirstOrDefault();
                    personRoleMapping.RoleId  = person_.RoleId;
                    personRoleMapping.Enabled = person_.Enabled;
                    context.SaveChanges();
                    contextTransaction.Commit();
                }
            }
            return(personResponse);
        }
Beispiel #2
0
        public PersonResponse PersonAdd(EH_Person person_)
        {
            decimal        personId;
            PersonResponse personResponse = new PersonResponse();

            using (EHContext context = new EHContext())
            {
                using (DbContextTransaction contextTransaction = context.Database.BeginTransaction())
                {
                    EH_Person person = new EH_Person()
                    {
                        PersonName   = person_.PersonName,
                        PersonMailID = person_.PersonMailID,
                        UserName     = person_.UserName,
                        Password     = person_.Password,
                        Enabled      = true,
                        Deleted      = false
                    };
                    context.EH_Person.Add(person);
                    context.SaveChanges();
                    personId = person.PersonId;

                    EH_PersonRoleMapping personRoleMapping = new EH_PersonRoleMapping()
                    {
                        PersonId = personId,
                        RoleId   = person_.RoleId,
                        Enabled  = true,
                        Deleted  = false
                    };

                    context.EH_PersonRoleMapping.Add(personRoleMapping);
                    context.SaveChanges();
                    contextTransaction.Commit();
                }
            }
            return(personResponse);
        }