public ActionResult <RoleOfGroup> PostRoleOfGroup(RoleOfGroupCM model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { RoleOfGroup roleOfGroup = new RoleOfGroup(); roleOfGroup = _mapper.Map <RoleOfGroup>(model); _roleOfGroupService.Create(roleOfGroup); _roleOfGroupService.Save(); return(StatusCode(201, "Role Of Group is created!")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <RoleOfGroup> PostRoleOfGroup(RoleOfGroupCM model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var checkExist = _roleOfGroupService.CheckExist(model.RoleID, model.GroupID); if (checkExist != null) { return(BadRequest("Existed!")); } RoleOfGroup roleOfGroup = new RoleOfGroup(); roleOfGroup = _mapper.Map <RoleOfGroup>(model); _roleOfGroupService.Create(roleOfGroup); return(StatusCode(201, roleOfGroup.ID)); } catch (Exception e) { return(BadRequest(e.Message)); } }