Esempio n. 1
0
        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"));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 public Division Create(Division objectToCreate)
 {
     repository.Add(objectToCreate);
     Save();
     return(objectToCreate);
 }