Exemplo n.º 1
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;
            }
        }