Exemple #1
0
        public ApiResult <bool> CreateDivision(CreateDivisionReqs request)
        {
            if (_divisionRepository.QueryByCityId(request.CityId) != null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "该城市分部已创建"));
            }

            Wizards wizard = _wizardRepository.Query(request.CreatorId);

            if (wizard == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "你是谁"));
            }

            long divisionId = NewId.GenerateId();

            var division = new Divisions(divisionId, request.CityId, request.Name, request.CreatorId);

            if (_divisionRepository.Insert(division) <= 0)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "保存时出错,请稍后再试"));
            }

            return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
        }
Exemple #2
0
 public bool Insert(DivisionParam divisionParam)
 {
     if (divisionParam != null)
     {
         status = _divisionRepository.Insert(divisionParam);
     }
     return(status);
 }
Exemple #3
0
        public bool Insert(DivisionVM divisionVM)
        {
            if (string.IsNullOrWhiteSpace(divisionVM.Name))

            {
                return(status);
            }
            else
            {
                var result = _divisionRepository.Insert(divisionVM);
                return(result);
            }
        }
Exemple #4
0
        public async Task <DivisionResponseDto> Dividir(DivisionRequestDto RequestDto)
        {
            var result = RequestDto.Dividendo / RequestDto.Divisor;

            RequestDto.Resultado   = result;
            RequestDto.IdOperacion = Guid.NewGuid();
            var response = await divisionRepository.Insert(_mapper.Map <DivisionEntity>(RequestDto)).ConfigureAwait(false);

            return(new DivisionResponseDto
            {
                IdOperacion = response.IdOperacion,
                Resultado = response.Resultado,
                StatusCode = response != null ? HttpStatusCode.OK : HttpStatusCode.Unauthorized,
                StatusDescription = response != null ? "Correo existe y esta activo" : "El correo no existe o esta innactivo"
            });
        }
Exemple #5
0
        public HttpResponseMessage Add(HttpRequestMessage request, DivisionDTO item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var dbObject = Mapper.Map <Division>(item);

            if (_instituteRepository.GetById(dbObject.InstituteId) == null)
            {
                return(request.CreateErrorResponse(
                           HttpStatusCode.PreconditionFailed,
                           string.Format("Not found institute with id: {0}", dbObject.InstituteId)));
            }

            _divisionRepository.Insert(dbObject);
            _db.SaveChanges();

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

            return(request.CreateResponse(HttpStatusCode.Created, mapped));
        }
        public ActionResult AddDivision(CreateDivision model)
        {
            if (ModelState.IsValid)
            {
                Division division = new Division
                {
                    Name      = model.Name,
                    Head      = model.Head,
                    CompanyId = brioContext.CurrentUser.CompanyId
                };

                try
                {
                    divisionRepository.Insert(division);
                    divisionRepository.SaveChanges();
                }
                catch (Exception e)
                {
                    TempData["IsSuccess"]      = false;
                    TempData["Message"]        = "Сохранение отдела закончилось неудачей. Попробуйте повторить попвтку.";
                    TempData["CreateDivision"] = model;
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["IsSuccess"]      = false;
                TempData["Message"]        = "Пожалуйста проверьте введенные данные.";
                TempData["CreateDivision"] = model;
                return(RedirectToAction("Index"));
            }

            TempData["IsSuccess"] = true;
            TempData["Message"]   = "Отдел успешно создан!";
            return(RedirectToAction("Index"));
        }