Пример #1
0
        public ActionResult Create(string editAction, string tablaId)
        {
            TablaDTO tablaDTO = new TablaDTO();

            switch (editAction)
            {
            case EditActionConstant.NEW:
                ViewBag.IsNew = true;
                break;

            case EditActionConstant.EDIT:
                ViewBag.IsNew = false;
                tablaDTO      = tablaService.GetById(Convert.ToInt32(tablaId));
                break;
            }
            return(PartialView(tablaDTO));
        }
Пример #2
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));
        }