private void AdjustDoListOverMaxSteps()
 {
     if (DoList.Count > _maxStep)
     {
         DoList = new Stack <T>(DoList.Take(_maxStep).Reverse());
     }
 }
Exemple #2
0
        public async Task <IActionResult> Edit(int id)
        {
            DoList item = await context.DoList.FindAsync(id);

            if (item == null)
            {
                return(NotFound());
            }

            return(View(item));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(DoList item)
        {
            if (ModelState.IsValid)
            {
                context.Update(item);
                await context.SaveChangesAsync();

                TempData["Success"] = "The task has been updated.";
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
        public T Redo()
        {
            if (RedoList.Count == 0)
            {
                return(default(T));
            }

            var redoAction = RedoList.Pop();

            DoList.Push(redoAction);

            return(redoAction);
        }
        public T Undo()
        {
            if (DoList.Count == 0)
            {
                return(default(T));
            }

            var undoAction = DoList.Pop();

            RedoList.Push(undoAction);

            return(undoAction);
        }
Exemple #6
0
        public ActionResult Guncelle(DoList doList)
        {
            var update = db.DoList.Find(doList.ID);

            if (update == null)
            {
                return(HttpNotFound());
            }
            update.toDo = doList.toDo;
            update.date = doList.date;
            db.SaveChanges();
            return(View("Index"));
        }
Exemple #7
0
        public async Task <IActionResult> Create(DoList item)
        {
            if (ModelState.IsValid)
            {
                item.Date = DateTime.Now;
                context.Add(item);
                await context.SaveChangesAsync();

                TempData["Success"] = "The task has been added.";
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Exemple #8
0
        public async Task <IActionResult> Delete(int id)
        {
            DoList item = await context.DoList.FindAsync(id);

            if (item == null)
            {
                TempData["Error"] = "The task was not found!";
            }
            else
            {
                context.DoList.Remove(item);
                await context.SaveChangesAsync();

                TempData["Success"] = "The task has been deleted.";
            }

            return(RedirectToAction("Index"));
        }
 public void Do(T t)
 {
     DoList.Push(t);
     AdjustDoListOverMaxSteps();
     RedoList.Clear();
 }
Exemple #10
0
 public JsonResult Ekle(DoList doList)
 {
     db.DoList.Add(doList);
     db.SaveChanges();
     return(Json("1"));
 }