コード例 #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));
        }
コード例 #2
0
        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);
        }
コード例 #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);
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
 public Division GetById(int id)
 {
     return(_divisionRepository.GetById(id));
 }
コード例 #6
0
        public Division GetById(int id)
        {
            var entity = repository.GetById(id);

            return(entity);
        }
コード例 #7
0
 public async Task <Division> GetById(int id)
 {
     return(await _divisionRepository.GetById(id));
 }