示例#1
0
        public async Task <ActionResult> ConfiguracionGeneral(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var empresa = await EntityService.GetByIdAsync(id.Value);

            if (empresa == null)
            {
                return(HttpNotFound());
            }

            var model = new EmpresaConfiguracionViewModel();

            model.Id = id;

            model.Ruc                    = empresa.Ruc;
            model.RazonSocial            = empresa.RazonSocial;
            model.NombreComercial        = empresa.NombreComercial;
            model.DireccionMatriz        = empresa.DireccionMatriz;
            model.ContribuyenteEspecial  = empresa.ContribuyenteEspecial;
            model.ObligadoContabilidad   = empresa.ObligadoContabilidad;
            model.NumeroEstablecimientos = empresa.NumeroEstablecimientos;
            model.Exportador             = empresa.Exportador;
            model.DocumentoPathId        = empresa.DocumentoPathId != null ? empresa.DocumentoPathId.Value : Guid.Empty;
            model.RecepcionTimeOut       = empresa.RecepcionTimeOut;
            model.AutorizacionTimeOut    = empresa.AutorizacionTimeOut;
            model.GeneraClaveAcceso      = empresa.GeneraClaveAcceso;
            model.InformacionAdicional1  = empresa.InformacionAdicional1;
            model.InformacionAdicional2  = empresa.InformacionAdicional2;
            model.InformacionAdicional3  = empresa.InformacionAdicional3;
            model.Telefonos              = empresa.Telefonos;
            model.ActividadEconomica     = empresa.ActividadEconomica;
            model.Decimales              = empresa.Decimales;

            if (empresa != null)
            {
                ViewBag.id  = empresa.Id;
                ViewBag.ruc = empresa.Ruc;

                CargarCombos(model);
            }
            return(View(model));
        }
示例#2
0
 private void CargarCombos(EmpresaConfiguracionViewModel model)
 {
     ViewBag.Decimaless = new SelectList(new List <SelectListItem>
     {
         new SelectListItem {
             Selected = false, Value = "2", Text = "2"
         },
         new SelectListItem {
             Selected = false, Value = "3", Text = "3"
         },
         new SelectListItem {
             Selected = false, Value = "4", Text = "4"
         },
         new SelectListItem {
             Selected = false, Value = "5", Text = "5"
         },
         new SelectListItem {
             Selected = false, Value = "6", Text = "6"
         },
     }, "Value", "Text", model.Decimales);
 }
示例#3
0
        public async Task <ActionResult> ConfiguracionGeneral(EmpresaConfiguracionViewModel model)
        {
            Empresa empresa = null;

            if (ModelState.IsValid)
            {
                empresa = await EntityService.GetByIdAsync(model.Id.Value);

                Mapper.Map(model, empresa);

                foreach (string fileName in Request.Files)
                {
                    HttpPostedFileBase files = Request.Files[fileName];
                    if (files != null && files.ContentLength > 0)
                    {
                        byte[] uploadFile = new byte[files.InputStream.Length];
                        files.InputStream.Read(uploadFile, 0, uploadFile.Length);
                        empresa.Imagen = uploadFile;
                    }
                }
                var result2 = await EntityService.SaveAsync(empresa);

                if (!result2.Succeeded)
                {
                    ModelState.AddModelError("", result2.GetErrorsString());
                }
            }

            if (empresa != null)
            {
                ViewBag.id  = empresa.Id;
                ViewBag.ruc = empresa.Ruc;
            }
            CargarCombos(model);
            return(View(model));
        }