Ejemplo n.º 1
0
        // GET: Home
        public ActionResult Index()
        {
            List <Task> tasks;

            using (var db = new SheetToDoContext())
            {
                tasks = db.Tasks.Where(task => !task.Archived).ToList();
            }
            return(View(tasks));
        }
Ejemplo n.º 2
0
 public IHttpActionResult GetUser([FromUri] string login, [FromUri] string password)
 {
     using (var db = new SheetToDoContext())
     {
         var user = db.Users.SingleOrDefault(u => u.Login.Equals(login) && u.Password.Equals(password));
         if (user != null)
         {
             return(Ok(new UserView(user.UserId, user.Login)));
         }
         return(NotFound());
     }
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "ID,Title,Description,Done")] Task task)
 {
     if (ModelState.IsValid)
     {
         using (var db = new SheetToDoContext())
         {
             db.Entry(task).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(task));
 }
Ejemplo n.º 4
0
 public ActionResult Archive(int?id)
 {
     using (var db = new SheetToDoContext())
     {
         Task task = db.Tasks.Find(id);
         if (task != null)
         {
             task.Archived = true;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Index")); // TODO: make error page inform about error
     }
 }
Ejemplo n.º 5
0
 // GET:
 public ActionResult Edit(int?id)
 {
     using (var db = new SheetToDoContext())
     {
         if (id == null)
         {
             return(RedirectToAction("Index"));
         }
         Task task = db.Tasks.Find(id);
         if (task == null)
         {
             return(HttpNotFound());
         }
         return(View(task));
     }
 }