public CreateRoleGroupResponse Create(CreateRoleGroupRequest request) { var response = new CreateRoleGroupResponse(); try { var roleGroup = request.MapTo<RoleGroup>(); roleGroup.Level = DataContext.Levels.FirstOrDefault(x => x.Id == request.LevelId); DataContext.RoleGroups.Add(roleGroup); DataContext.SaveChanges(); response.IsSuccess = true; response.Message = "RoleGroup type item has been added successfully"; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return response; }
public CreateRoleGroupResponse Create(CreateRoleGroupRequest request) { var response = new CreateRoleGroupResponse(); try { var roleGroup = request.MapTo <RoleGroup>(); roleGroup.Level = DataContext.Levels.FirstOrDefault(x => x.Id == request.LevelId); DataContext.RoleGroups.Add(roleGroup); DataContext.SaveChanges(); response.IsSuccess = true; response.Message = "RoleGroup type item has been added successfully"; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return(response); }