Пример #1
0
 // GET: Grids
 public ActionResult Index()
 {
     if (!(Session.Count > 0) || !((bool)Session["UserLoggedIn"] == true))
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         string        account = Session["Account"].ToString();
         LifeHelper    lh      = new LifeHelper(db);
         Life          life    = lh.GetLifeByAccount(account);
         LifeViewModel lvm     = new LifeViewModel(life);
         return(View(lvm));
     }
 }
Пример #2
0
 // GET: Things
 public ActionResult Index(int ID = -1)
 {
     if (!(Session.Count > 0) || !((bool)Session["UserLoggedIn"] == true) || ID == -1)
     {
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         LifeHelper    lh        = new LifeHelper(db);
         Life          thisLife  = lh.GetLifeByAccount(Session["Account"].ToString());
         int           dayNumber = ID;
         DateTime      thisDay   = thisLife.Birthday.AddDays(dayNumber);
         Grid          thisGrid  = lh.GetGridByDate(thisDay, thisLife);
         GridViewModel gvm       = new GridViewModel(thisLife, thisGrid);
         return(View(gvm));
     }
 }
Пример #3
0
        public ActionResult AddNewThing(FormCollection fc)
        {
            int      id       = Convert.ToInt32(fc["txtIdHidden"]);
            string   temp     = fc["txtDateHidden"];
            DateTime date     = Convert.ToDateTime(temp);
            string   content  = fc["taContent"];
            Thing    newThing = new Thing
            {
                Content    = content,
                CreateTime = DateTime.Now,
                State      = Thing.ThingState.Doing,
                StopTime   = null
            };
            LifeHelper lh       = new LifeHelper(db);
            Life       life     = lh.GetLifeByAccount(Session["Account"].ToString());
            Grid       thisGrid = lh.GetGridByDate(date, life);

            thisGrid.Things = new List <Thing>();
            thisGrid.Things.Add(newThing);
            life.Grids.Add(thisGrid);
            db.SaveChanges();
            return(RedirectToAction("Index", new { ID = id }));
        }