Exemplo n.º 1
0
        public ActionResult Create(JsonHeader collection)
        {
            TablaDTO tablaDTO = new TablaDTO();
            Dictionary <string, string> editDictionary    = WebHelper.JsonToDictionary(collection.Header);
            JsonResultMessage           jsonResultMessage = new JsonResultMessage();

            try
            {
                if (collection.EditAction == EditActionConstant.EDIT)
                {
                    tablaDTO.TablaId = Convert.ToInt32(editDictionary["TablaId"]);
                }

                tablaDTO.Codigo  = Convert.ToString(editDictionary["Codigo"]);
                tablaDTO.Nombre  = Convert.ToString(editDictionary["Nombre"]);
                tablaDTO.Formato = editDictionary["Formato"].ToString();


                tablaDTO.Estado            = EstadoConstante.ACTIVO;
                tablaDTO.UsuarioCreacionId = 1;
                tablaDTO.FechaCreacion     = DateTime.Now;

                if (collection.EditAction == EditActionConstant.NEW)
                {
                    tablaService.Create(tablaDTO);
                }
                else
                {
                    tablaService.Update(tablaDTO);
                }

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