示例#1
0
 public bool Existe(CarteraDeConsumoEditDto carteraDeConsumoDto)
 {
     try
     {
         CarteraDeConsumo cc = _mapper.Map <CarteraDeConsumo>(carteraDeConsumoDto);
         return(_repositorio.Existe(cc));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#2
0
 public void Guardar(CarteraDeConsumoEditDto carteraDeConsumoDto)
 {
     try
     {
         CarteraDeConsumo cc = _mapper.Map <CarteraDeConsumo>(carteraDeConsumoDto);
         _repositorio.Guardar(cc);
         _unitOfWork.Save();
         carteraDeConsumoDto.CarteraDeConsumoId = cc.CarteraDeConsumoId;
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#3
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            CarteraDeConsumoEditDto ccDto = _servicio.GetCarteraDeConsumoId(id);

            if (ccDto == null)
            {
                return(HttpNotFound("Registro inexistente"));
            }

            CarteraDeConsumoEditViewModel ccVm = _mapper.Map <CarteraDeConsumoEditViewModel>(ccDto);

            return(View(ccVm));
        }
示例#4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            CarteraDeConsumoEditDto       ccDto = _servicio.GetCarteraDeConsumoId(id);
            CarteraDeConsumoEditViewModel ccVm  = _mapper.Map <CarteraDeConsumoEditViewModel>(ccDto);

            if (ccVm.Imagen == null)
            {
                ccVm.Imagen = $"SinImagenDisponible.jpg";
            }
            else
            {
                ccVm.Imagen = $"{ccVm.Imagen}";
            }
            return(View(ccVm));
        }
示例#5
0
        public ActionResult Create(CarteraDeConsumoEditViewModel ccVm)
        {
            if (!ModelState.IsValid)
            {
                ccVm.Imagen = $"SinImagenDisponible.jpg";
                return(View(ccVm));
            }

            CarteraDeConsumoEditDto ccDto = _mapper.Map <CarteraDeConsumoEditDto>(ccVm);

            if (_servicio.Existe(ccDto))
            {
                ModelState.AddModelError(string.Empty, "Registro repetido");
                ccVm.Imagen = $"SinImagenDisponible.jpg";
                return(View(ccVm));
            }

            try
            {
                if (ccVm.ImagenFile != null)
                {
                    ccDto.Imagen = $"{ccVm.ImagenFile.FileName}";
                }
                _servicio.Guardar(ccDto);
                if (ccVm.ImagenFile != null)
                {
                    var file     = $"{ccVm.ImagenFile.FileName}";
                    var response = FileHelper.UploadPhoto(ccVm.ImagenFile, folder, file);
                }
                TempData["Msg"] = "Nueva cartera de consumo guardada";
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                ccVm.Imagen = $"SinImagenDisponible.jpg";
                return(View(ccVm));
            }
        }