Example #1
0
        public AccountGroupResponseDto EditAccountGroup(AccountGroupDto accountGroup, int id)
        {
            var accountGroupFromDb = db.AccountGroups.FirstOrDefault(x => !x.DelFlag && x.Id == id);

            accountGroupFromDb.Name        = accountGroup.Name;
            accountGroupFromDb.Description = accountGroup.Description;
            db.SaveChanges();
            return(new AccountGroupResponseDto(accountGroupFromDb));
        }
Example #2
0
        public AccountGroupResponseDto AddAccountGroup(AccountGroupDto accountGroup)
        {
            var accountGroupdb = new Database.Schema.Entity.AccountGroup {
                Name = accountGroup.Name, Description = accountGroup.Description
            };

            db.AccountGroups.Add(accountGroupdb);
            db.SaveChanges();
            return(new AccountGroupResponseDto(accountGroupdb));
        }
Example #3
0
        public IHttpActionResult EditAccountGroup(int id, [FromBody] AccountGroupDto accountGroup)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                return(Ok(_accountGroupManagementService.EditAccountGroup(accountGroup, id)));
            }
            catch (System.Exception e)
            {
                return(InternalServerError(e));
            }
        }