public async Task <ActionResult <Division> > CreateDivision(Division division) { if (await _divisionRepository.DivisionExists(division.DivisionName, division.CompanyId)) { return(BadRequest("A Division with the name '" + division.DivisionName + "' already exists for this company")); } _divisionRepository.Add(division); if (await _divisionRepository.SaveAllAsync()) { return(NoContent()); } return(BadRequest("Failed to add division")); }
public bool CreateDivision(Division division) { bool isSuccess = true; try { divisionRepository.Add(division); this.SaveRecord(); ServiceUtil <Division> .WriteActionLog(division.Id, ENUMOperation.CREATE, division); } catch (Exception ex) { isSuccess = false; logger.Error("Error in creating Division", ex); } return(isSuccess); }
public async Task <CreateDivisionResponse> CreateOrUpdateDivisionAsync(Division division) { // TODO :: CHECK IF GROUP SCORE FILTER BELONGS TO TOKEN USER //https://stackoverflow.com/questions/46112258/how-do-i-get-current-user-in-net-core-web-api-from-jwt-token if (division.Id == 0) { _divisionRepository.Add(division); } else { _divisionRepository.Update(division); } await _unitOfWork.CompleteAsync(); return(new CreateDivisionResponse(true, null, division)); }
public Division Create(Division objectToCreate) { repository.Add(objectToCreate); Save(); return(objectToCreate); }