Beispiel #1
0
        public ActionResult Edit(ContactosFormModel contactoVM)
        {
            if (ModelState.IsValid)
            {
                Contacto contacto = new Contacto();
                contacto.Id = contactoVM.Id;

                contacto.Nombre         = contactoVM.Nombre;
                contacto.Domicilio      = contactoVM.Domicilio;
                contacto.ConstructoraId = contactoVM.ConstructoraId;
                ContactoService.Update(contacto);

                return(Json(new { data = true }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { data = false }, JsonRequestBehavior.AllowGet));
        }
        public IActionResult GuardarImagen(int idContacto, IFormFile foto)
        {
            try
            {
                var contacto = contactoService.GetByIdContacto(idContacto);
                var savePath = System.IO.Path.Combine(Startup.entorno.WebRootPath, "uploads");
                contacto.Ruta = FotosService.SubirFotoContacto(foto, savePath);

                contactoService.Update(contacto);

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");
                return(BadRequest());

                throw;
            }
        }
Beispiel #3
0
        public ActionResult ContactoGuardar(JsonHeader collection)
        {
            Dictionary <string, string> headerDictionary  = WebHelper.JsonToDictionary(collection.Header);
            Dictionary <string, string> detailDictionary  = WebHelper.JsonToDictionary(collection.Detail);
            JsonResultMessage           jsonResultMessage = new JsonResultMessage();
            ContactoDTO contactoDTO = new ContactoDTO();

            try
            {
                contactoDTO.ContactoId              = Convert.ToInt32(detailDictionary["ContactoId"]);
                contactoDTO.ProveedorId             = Convert.ToInt32(headerDictionary["ProveedorId"]);
                contactoDTO.AreaId                  = Convert.ToInt32(detailDictionary["AreaId"]);
                contactoDTO.NombreContacto          = detailDictionary["NombreContacto"].ToUpper().ToString();
                contactoDTO.NumeroDocumentoContacto = detailDictionary["NumeroDocumentoContacto"].ToString().Trim();
                contactoDTO.TelefonoContacto        = detailDictionary["TelefonoContacto"].Trim();
                contactoDTO.CelularContacto         = detailDictionary["CelularContacto"].Trim();
                contactoDTO.DireccionContacto       = detailDictionary["DireccionContacto"].Trim();
                contactoDTO.EmailContacto           = detailDictionary["EmailContacto"].Trim();
                contactoDTO.Estado                  = EstadoConstante.ACTIVO;
                if (collection.EditAction == EditActionConstant.NEW)
                {
                    _contactoService.InsertarContacto(contactoDTO);
                }
                else
                {
                    _contactoService.Update(contactoDTO);
                }


                jsonResultMessage.message = "Contacto grabado satisfactoriamente.";
                return(Json(jsonResultMessage));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Create(JsonHeader collection)
        {
            Dictionary <string, string> headerDictionary  = WebHelper.JsonToDictionary(collection.Header);
            JsonResultMessage           jsonResultMessage = new JsonResultMessage();
            ContactoDTO contactoDTO = new ContactoDTO();

            try
            {
                contactoDTO.ContactoId              = Convert.ToInt32(headerDictionary["ContactoId"]);
                contactoDTO.AreaId                  = Convert.ToInt32(headerDictionary["AreaId"]);
                contactoDTO.NombreContacto          = headerDictionary["NombreContacto"].ToString();
                contactoDTO.NumeroDocumentoContacto = headerDictionary["NumeroDocumentoContacto"].ToString();
                contactoDTO.TelefonoContacto        = headerDictionary["TelefonoContacto"].ToString();
                contactoDTO.CelularContacto         = headerDictionary["CelularContacto"].ToString();
                contactoDTO.EmailContacto           = headerDictionary["EmailContacto"].ToString();
                contactoDTO.DireccionContacto       = headerDictionary["DireccionContacto"].ToString();

                if (collection.EditAction == EditActionConstant.NEW)
                {
                    contactoService.Create(contactoDTO);
                }
                else
                {
                    contactoService.Update(contactoDTO);
                }

                jsonResultMessage.message = "Contacto grabado satisfactoriamente.";
                return(Json(jsonResultMessage));
            }
            catch (Exception ex)
            {
                jsonResultMessage.success = false;
                jsonResultMessage.message = ex.Message;
            }
            return(Json(jsonResultMessage));
        }