Пример #1
0
        public static void Create(RoleDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var entity = RoleMapper.DtoToEntity(dto);

                db.RoleSet.Add(entity);
                db.SaveChanges();
            }
        }
Пример #2
0
        public static void Update(RoleDto dto)
        {
            using (var db = new MainDBModelContainer())
            {
                var newData = RoleMapper.DtoToEntity(dto);
                var oldData = db.RoleSet.Find(dto.Id);
                if (oldData != null)
                {
                    oldData.FriendlyName = newData.FriendlyName;
                    oldData.SysRole      = newData.SysRole;

                    db.SaveChanges();
                }
                else
                {
                    throw new ElementNotFoundException();
                }
            }
        }