예제 #1
0
        public ActionResult Create(EventModel Model)
        {
            try
            {
                if (Model.EventNo == 0)
                {
                    tblEventCalendar Events = new tblEventCalendar();
                    Events.CreatedBy        = _session.User_Id;
                    Events.CreatedDate      = DateTime.Now;
                    Events.SchoolId         = _session.School_Id;
                    Events.EventTitle       = Model.EventName;
                    Events.EventCategory    = Model.EventCategoryId;
                    Events.EventDescription = Model.EventDescription;
                    Events.EventOrganizer   = Model.EventOrganizer;
                    Events.FromDate         = Convert.ToDateTime(Model.SFromDate);
                    Events.ToDate           = Convert.ToDateTime(Model.SToDate);

                    DateTime F = DateTime.Parse(Model.SFromTime);
                    DateTime T = DateTime.Parse(Model.SToTime);

                    Events.FromTime = TimeSpan.Parse(F.ToString("HH:mm"));
                    Events.ToTime   = TimeSpan.Parse(T.ToString("HH:mm"));
                    Events.IsActive = "Y";

                    Connection.tblEventCalendars.Add(Events);
                    Connection.SaveChanges();
                }
                else
                {
                    tblEventCalendar Events = Connection.tblEventCalendars.SingleOrDefault(
                        x => x.EventNo == Model.EventNo);

                    Events.CreatedBy        = _session.User_Id;
                    Events.CreatedDate      = DateTime.Now;
                    Events.SchoolId         = _session.School_Id;
                    Events.EventTitle       = Model.EventName;
                    Events.EventCategory    = Model.EventCategoryId;
                    Events.EventDescription = Model.EventDescription;
                    Events.EventOrganizer   = Model.EventOrganizer;
                    Events.FromDate         = Convert.ToDateTime(Model.SFromDate);
                    Events.ToDate           = Convert.ToDateTime(Model.SToDate);

                    DateTime F = DateTime.Parse(Model.SFromTime);
                    DateTime T = DateTime.Parse(Model.SToTime);
                    Events.FromTime = TimeSpan.Parse(F.ToString("HH:mm"));
                    Events.ToTime   = TimeSpan.Parse(T.ToString("HH:mm"));
                    Events.IsActive = "Y";

                    Connection.SaveChanges();
                }
                return(Json("Succsess", JsonRequestBehavior.AllowGet));
            }
            catch (Exception Ex)
            {
                var result = new { r = "E" };
                Errorlog.ErrorManager.LogError("@EventController/Create", Ex);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
 public ActionResult Delete(EventModel Model)
 {
     try
     {
         tblEventCalendar DEvents = Connection.tblEventCalendars.Find(Model.EventNo);
         Connection.tblEventCalendars.Remove(DEvents);
         Connection.SaveChanges();
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception Ex)
     {
         Errorlog.ErrorManager.LogError("@EventController/Delete", Ex);
         return(View());
     }
 }
예제 #3
0
        public ActionResult Indexx(int txtID, string btnAgregar, string btnEditar, string btnEliminar, string txtFechaInicio, string txtFechaFin, string txtTitulo, string txtHora, string txtDescripcion, string txtColor, tblEventCalendar ev)
        {
            if (Request.HttpMethod == "POST")
            {
                if (btnAgregar == "agregar")
                {
                    var datosevento = new tblEventCalendar
                    {
                        id_Event    = txtID,
                        title       = txtTitulo,
                        descripcion = txtDescripcion,
                        color       = txtColor,
                        textColor   = "#FFFFFF",
                        start       = Convert.ToDateTime(txtFechaInicio + " " + txtHora),
                        end         = Convert.ToDateTime(txtFechaFin + " " + txtHora)
                    };
                    db.tblEventCalendar.Add(datosevento);
                    db.SaveChanges();

                    /*NOTIFICACION*/
                    ApplicationDbContext dbs          = new ApplicationDbContext();
                    Notifications        notificacion = new Notifications();
                    notificacion.Module     = "Eventos";
                    notificacion.Message    = string.Format("Registro un nuevo evento");
                    notificacion.Date       = DateTime.Now;
                    notificacion.Viewed     = false;
                    notificacion.Usuario_Id = User.Identity.GetUserId();

                    dbs.Notification.Add(notificacion);
                    dbs.SaveChanges();
                    /*FIN NOTIFICACION*/

                    return(RedirectToAction("Index", "Home"));
                }
                else if (btnEditar == "editar")
                {
                    var datosevento = new tblEventCalendar
                    {
                        id_Event    = txtID,
                        title       = txtTitulo,
                        descripcion = txtDescripcion,
                        color       = txtColor,
                        textColor   = "#FFFFFF",
                        start       = Convert.ToDateTime(txtFechaInicio),
                        end         = Convert.ToDateTime(txtFechaFin)
                    };
                    db.tblEventCalendar.Attach(datosevento);
                    db.Entry(datosevento).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    /*NOTIFICACION*/
                    ApplicationDbContext dbs          = new ApplicationDbContext();
                    Notifications        notificacion = new Notifications();
                    notificacion.Module     = "Eventos";
                    notificacion.Message    = string.Format("Edito un evento");
                    notificacion.Date       = DateTime.Now;
                    notificacion.Viewed     = false;
                    notificacion.Usuario_Id = User.Identity.GetUserId();

                    dbs.Notification.Add(notificacion);
                    dbs.SaveChanges();
                    /*FIN NOTIFICACION*/

                    return(RedirectToAction("Index", "Home"));
                }
                else if (btnEliminar == "eliminar")
                {
                    var datosevento = new tblEventCalendar
                    {
                        id_Event    = txtID,
                        title       = txtTitulo,
                        descripcion = txtDescripcion,
                        color       = txtColor,
                        textColor   = "#FFFFFF",
                        start       = Convert.ToDateTime(txtFechaInicio),
                        end         = Convert.ToDateTime(txtFechaFin)
                    };
                    db.tblEventCalendar.Attach(datosevento);
                    db.tblEventCalendar.Remove(datosevento);
                    db.SaveChanges();

                    /*NOTIFICACION*/
                    ApplicationDbContext dbs          = new ApplicationDbContext();
                    Notifications        notificacion = new Notifications();
                    notificacion.Module     = "Eventos";
                    notificacion.Message    = string.Format("Elimino un evento");
                    notificacion.Date       = DateTime.Now;
                    notificacion.Viewed     = false;
                    notificacion.Usuario_Id = User.Identity.GetUserId();

                    dbs.Notification.Add(notificacion);
                    dbs.SaveChanges();
                    /*FIN NOTIFICACION*/

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }