public ActionResult Create(TaskViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                var task    = model.ToModel();
                var newTask = tasksService.Add(task);

                return(Json(newTask, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public ActionResult Create(TaskViewModel model)
        {
            try
            {
                // TODO: Add insert logic here
                var task = model.ToModel();
                tasksService.Add(task);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #3
0
        public static void AddItemToTaskList()
        {
            Tasks    task          = new Tasks();
            string   _input        = string.Empty;
            DateTime _dateTime     = new DateTime();
            bool     _errorPresent = false;

            do
            {
                Console.WriteLine("Please enter a description of the task you would like completed.");
                _input           = Console.ReadLine();
                task.Description = _input;
                Console.WriteLine("Please enter a name of the person who you would like to complete the task.");
                _input        = Console.ReadLine();
                task.Assignee = _input;
                Console.WriteLine("Please enter the day you would like the task completed in MM/DD/YYYY format.");
                _input = Console.ReadLine();
                DateTime.TryParse(_input, out _dateTime);
                task.DueDate  = _dateTime;
                _errorPresent = !task.IsValid();
                if (_errorPresent)
                {
                    Console.WriteLine("Sorry, but that was not a valid task. Please try again.");
                }
            } while (_errorPresent);
            service.Add(task);
            MainMenu();
        }
Example #4
0
        public ActionResult Create(TasksViewModel tvm, ProjectViewModel pvm, WebApplication1.Models.Entities.User uvm, DifficulteViewModel d)
        {
            var p = Ps.GetAll();

            foreach (var item in p)
            {
                ProjectViewModel Pvm = new ProjectViewModel();
                Pvm.projectId   = item.projectId;
                Pvm.projectname = item.projectname;
                Pvm.categoryId  = item.categoryId;
                Pvm.description = item.description;
                Pvm.plan        = item.plan;
                Pvm.goals       = item.goals;
                Pvm.state       = (WebApplication1.Models.stat)stat.To_Do;
            }
            ViewBag.pro = new SelectList(p, "projectId", "projectname");


            var u = Us.GetAll();

            foreach (var item in u)
            {
                Models.Entities.User Uvm = new Models.Entities.User();
                Uvm.Id = item.Id;
            }
            ViewBag.usr = new SelectList(u, "Id", "Id");

            var D = Ds.GetAll();

            foreach (var item in D)
            {
                DifficulteViewModel df = new DifficulteViewModel();
                df.DifficulteId = item.DifficulteId;
            }
            ViewBag.diff = new SelectList(D, "DifficulteId", "DifficulteId");

            Tasks t = new Tasks();

            t.tasksId       = tvm.taskId;
            t.projectId     = pvm.projectId;
            t.team_memberId = uvm.Id;
            // p.deadline = pvm.deadline;
            //t.duration = tvm.duration;
            //t.state = (Domain.Entities.stat)stat.To_Do;
            t.DifficulteId = d.DifficulteId;
            t.nomtask      = tvm.nomtask;
            Ts.Add(t);
            Ts.Commit();

            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #5
0
        // PUT api/Default1/5
        public HttpResponseMessage PutTodo(int id, Task todo)
        {
            if (ModelState.IsValid && id == todo.Id)
            {
                try
                {
                    tasksService.Add(todo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        public void Add(int id, string description, int duration)
        {
            Task t = new Task()
            {
                Id          = id,
                Description = description,
                Duration    = duration
            };

            _val.Validate(t);
            _service.Add(t);
        }
Example #7
0
 public ActionResult Create(Tasks task)
 {
     try
     {
         if (task.IsValid())
         {
             service.Add(task);
             return(new HttpStatusCodeResult(HttpStatusCode.OK));
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
     }
     catch
     {
         return(View());
     }
 }