public ActionResult Create([Bind(Include = "Task2ID,TaskDescription,Done,DateStarted,DateCompleted,Category,UserID,Deadline")] Task2 task2)
        {
            if (ModelState.IsValid)
            {
                db.Task2s.Add(task2);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Category = new SelectList(db.Categories, "CategoryID", "CategoryName", task2.Category);
            ViewBag.UserID   = new SelectList(db.Users, "UserID", "UserName", task2.UserID);
            return(View(task2));
        }
Ejemplo n.º 2
0
        public OperationResult AddTasks(ItemsViewModel items)
        {
            var result = new OperationResult();

            try
            {
                ToDoModel  context    = new ToDoModel();
                var        repository = new ToDoRepository <WorkDetail>(context);
                WorkDetail entity     = new WorkDetail()
                {
                    WorkContent    = items.WorkContent,
                    Important      = items.IsImportant ? "Y" : "N",
                    Complete       = items.Completed ? "Y" : "N",
                    CreationDate   = DateTime.Now,
                    PlanDate       = items.PlanedDate,
                    LastUpdateDate = DateTime.Now
                };

                repository.Create(entity);
                context.SaveChanges();
                result.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public OperationResult Delete(int id)
        {
            var result = new OperationResult();

            try
            {
                ToDoModel context    = new ToDoModel();
                var       repository = new ToDoRepository <WorkDetail>(context);
                var       FindById   = repository.GetAll().Where((x) => x.Id == id).FirstOrDefault();
                repository.Delete(FindById);
                context.SaveChanges();
                result.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }

            return(result);
        }
Ejemplo n.º 4
0
        public OperationResult Important(int id)
        {
            var result = new OperationResult();

            try
            {
                ToDoModel context    = new ToDoModel();
                var       repository = new ToDoRepository <WorkDetail>(context);
                var       FindById   = repository.GetAll().Where((x) => x.Id == id).FirstOrDefault();
                FindById.Important      = FindById.Important == "N" ? "Y" : "N";
                FindById.LastUpdateDate = DateTime.Now;
                repository.Update(FindById);
                context.SaveChanges();
                result.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }

            return(result);
        }
Ejemplo n.º 5
0
 public void Update(T entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }