Exemple #1
0
        public HttpResponseMessage GetEmployeesInDivision(HttpRequestMessage request, int divisionId)
        {
            var division = _divisionRepository.GetById(divisionId);

            if (division == null)
            {
                return(request.CreateErrorResponse(
                           HttpStatusCode.NotFound,
                           string.Format("Not found division with id:{0}", divisionId)));
            }

            var mapped = division.Employees.Select(Mapper.Map <EmployeeDTO>).ToList();

            return(request.CreateResponse(mapped));
        }
        public bool DeleteDivision(int id)
        {
            bool isSuccess = true;
            var  division  = divisionRepository.GetById(id);

            try
            {
                divisionRepository.Delete(division);
                SaveRecord();
                ServiceUtil <Division> .WriteActionLog(id, ENUMOperation.DELETE);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in deleting Division", ex);
            }
            return(isSuccess);
        }
Exemple #3
0
        public DivisionDTO GetDivisionById(int divisonId)
        {
            var division = _divisionRepository.GetById(divisonId);

            if (division == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var mapped = Mapper.Map <DivisionDTO>(division);

            return(mapped);
        }
        public ActionResult DeleteDivision(int id)
        {
            if (id > 0)
            {
                Division d = divisionRepository.GetById(id);
                divisionRepository.Delete(d);
                divisionRepository.SaveChanges();

                TempData["IsSuccess"] = true;
                TempData["Message"]   = "Отдел успешно удален!";
            }
            else
            {
                TempData["IsSuccess"] = false;
                TempData["Message"]   = "Произошла ошибка, пожалуйста повторите попытку!";
            }

            return(RedirectToAction("Index"));
        }
Exemple #5
0
 public Division GetById(int id)
 {
     return(_divisionRepository.GetById(id));
 }
Exemple #6
0
        public Division GetById(int id)
        {
            var entity = repository.GetById(id);

            return(entity);
        }
 public async Task <Division> GetById(int id)
 {
     return(await _divisionRepository.GetById(id));
 }