Example #1
0
        public ActionResult Maintain(PQRSModel mdlPQRS)
        {
            try
            {
                ViewBag.Title = EnumHelper<Operation.Status>.GetDisplayValue((Operation.Status)mdlPQRS.Operation);
                ViewBag.Subtitle = String.Format("{0} PQRS", ViewBag.Title);

                if (   (mdlPQRS.Operation == (int)Operation.Status.Update && AdminSession.Current.Logued)
                    || (mdlPQRS.Operation == (int)Operation.Status.Create && !AdminSession.Current.Logued))
                {
                    if (ModelState.IsValid)
                    {
                        DateTime l_dtmNow = DateTime.Now;
                        DateTime l_dtmFecha = (DateTime)(mdlPQRS.Fecha == null ? l_dtmNow : mdlPQRS.Fecha);
                        DateTime l_dtmHora = (DateTime)(mdlPQRS.Hora == null ? l_dtmNow : mdlPQRS.Hora);
                        DateTime l_dtmFechaHora = new DateTime(l_dtmFecha.Year, l_dtmFecha.Month, l_dtmFecha.Day, l_dtmHora.Hour, l_dtmHora.Minute, l_dtmHora.Second);

                        int l_intRec = _repository.Save(
                            mdlPQRS.Operation,
                            mdlPQRS.ID,
                            mdlPQRS.TipoPQRS,
                            mdlPQRS.Asunto,
                            mdlPQRS.Descripcion,
                            mdlPQRS.Nombres,
                            mdlPQRS.Email,
                            mdlPQRS.Gestionada,
                            l_dtmFechaHora
                        );

                        if (l_intRec < 1)
                        {
                            throw new Exception("No se realizó ninguna operación por favor intentelo nuevamente");
                        }
                        if (mdlPQRS.Operation == (int)Operation.Status.Create)
                        {
                            string l_strTipo = EnumHelper<EnumModel.TipoPQRS>.GetDisplayValue((EnumModel.TipoPQRS)mdlPQRS.TipoPQRS);
                            Success(string.Format("Su <b>{0}</b> ha sido radicada con éxito.", l_strTipo), true);
                        }
                        return RedirectToAction(AdminSession.Path);

                    }
                    else
                    {
                        throw new Exception("Los datos no son validos");
                    }
                }
                else
                {
                    throw new Exception("Acceso denegado. Verifique que sus credenciales o sesión se encuentren activas.");
                }
            }
            catch (Exception ex)
            {
                Danger(ex.Message, true);
                return View(mdlPQRS);
            }
        }
Example #2
0
        public ActionResult Maintain(int id, int operation)
        {
            try
            {
                if (   (operation == (int)Operation.Status.Update && AdminSession.Current.Logued)
                    || (operation == (int)Operation.Status.Create && !AdminSession.Current.Logued))
                {
                    ViewBag.Title = EnumHelper<Operation.Status>.GetDisplayValue((Operation.Status)operation);
                    ViewBag.Subtitle = String.Format("{0} PQRS", ViewBag.Title);

                    PQRSModel mdlPQRS = new PQRSModel();
                    if (operation == (int)Operation.Status.Update)
                    {
                        mdlPQRS = _repository.Get(id);
                    }
                    mdlPQRS.Operation = (int)operation;

                    return View(mdlPQRS);
                }
                else
                {
                    throw new Exception("Acceso denegado. Verifique que sus credenciales o sesión se encuentren activas.");
                }
            }
            catch (Exception ex)
            {
                Danger(ex.Message, true);
                return RedirectToAction("Index", "Home");
            }
        }