public ActionResult PostAddTaskGroup(TaskGroup taskGroup) { db.TaskGroups.Add(taskGroup); db.SaveChanges(); return(Redirect("/TaskGroup/Index")); }
public IHttpActionResult PutTask(int id, Task task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != task.Task_Id) { return(BadRequest()); } db.Entry(task).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public int Save(Task task) { Task dbTask; if (task.Id > 0) { dbTask = _db.Tasks.Find(task.Id); if (dbTask != null) { dbTask.Name = task.Name; dbTask.ModifiedDate = DateTime.Now; dbTask.DueDate = task.DueDate; } } else { task.EntryDate = DateTime.Now; task.ModifiedDate = DateTime.Now; dbTask = _db.Tasks.Add(task); } _db.SaveChanges(); return(dbTask.Id); }
public void TestMethod6() { var options = new DbContextOptionsBuilder <TaskManagerContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; TaskManagerContext context = new TaskManagerContext(options); context.Statuses.AddRange(Status.GetAll()); context.SaveChanges(); Task[] tasks = new Task[] { new Task() { EndDate = DateTime.Now, Status = Status.Complete }, new Task() { EndDate = DateTime.Now, Status = Status.New }, new Task() { EndDate = DateTime.Now, Status = Status.Cancelled } }; context.Tasks.AddRange(tasks); context.SaveChanges(); Assert.AreEqual(3, context.Tasks.Count()); }
public ActionResult Index(string memberName, string last_name, string[] selectedTask) { //find name in the db var student = db.Students .Where(s => s.name == memberName && s.lastName == last_name) .FirstOrDefault(); if (student != null && selectedTask != null) { foreach (string checkedTask in selectedTask) //loop through the checked tasks { var taskId = Int32.Parse(checkedTask); //selectedTask returns the values of checkboxes -id //add a new task in the status table db.Status.Add(new Status { TasksID = taskId, StudentsID = student.StudentsID, status = "active", dateSubmitted = DateTime.Now, dateAdded = DateTime.Now }); db.SaveChanges(); } return(RedirectToAction("MyTasks", student)); } else { return(RedirectToAction("Index")); } //db.Students.FirstOrDefault(i => i.StudentsID == 1) }
public ActionResult PostAddTask(Task task) { db.Tasks.Add(task); db.SaveChanges(); return(Redirect("/Task/Index")); }
public ActionResult PostAddTaskStatus(TaskStatus taskStatus) { db.TaskStatuses.Add(taskStatus); db.SaveChanges(); return(Redirect("/TaskStatus/Index")); }
public ActionResult PostAddTaskPriority(TaskPriority taskPriority) { db.TaskPriorities.Add(taskPriority); db.SaveChanges(); return(Redirect("/TaskPriority/Index")); }
public int Save(SubTask subTask) { //subTask.EntryDate = DateTime.Now; //subTask.ModifiedDate = DateTime.Now; //var result = _db.SubTasks.Add(subTask); //_db.SaveChanges(); //return result.Id; SubTask dbSubTask; if (subTask.Id > 0) { dbSubTask = _db.SubTasks.Find(subTask.Id); if (dbSubTask != null) { dbSubTask.Name = subTask.Name; dbSubTask.ModifiedDate = DateTime.Now; dbSubTask.Description = subTask.Description; dbSubTask.taskId = subTask.taskId; } } else { subTask.EntryDate = DateTime.Now; subTask.ModifiedDate = DateTime.Now; dbSubTask = _db.SubTasks.Add(subTask); } _db.SaveChanges(); return(dbSubTask.Id); }
public ActionResult PostAddTaskBoard(TaskBoard taskBoard) { db.TaskBoards.Add(taskBoard); db.SaveChanges(); return(Redirect("/TaskBoard/Index")); }
public ActionResult PostAddTaskSubelement(TaskSubelement taskSubelement) { db.TaskSubelements.Add(taskSubelement); db.SaveChanges(); return(Redirect("/TaskSubelement/Index")); }
public bool Add(Task task) { try { if (task.AllDay == true) { task.End = null; } if (task.Start > task.End && task.AllDay == false) { return(false); } _taskManagerContext.Tasks.Add(task); _taskManagerContext.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public void AddItem(T addItem) { context.Set <T>().Add(addItem); var changes = context.ChangeTracker.Entries(); context.SaveChanges(); }
public bool AddTask(TaskDTO task) { Task taskData = _mapper.Map <Task>(task); _context.tasks.Add(taskData); _context.SaveChanges(); return(true); }
public ActionResult AddUser(User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(Redirect("/User/Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "TasksID,name,description,deadline")] Tasks tasks) { if (ModelState.IsValid) { db.Tasks.Add(tasks); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tasks)); }
public void Create(Author author) { if (!ReferenceEquals(author, null)) { throw new ArgumentNullException(); } _context.Authors.Add(author); _context.SaveChanges(); _context.Dispose(); }
public void Create(Task task) { if (ReferenceEquals(task, null)) { throw new ArgumentNullException(); } _context.Tasks.Add(task); _context.SaveChanges(); _context.Dispose(); }
public ActionResult Create([Bind(Include = "Id,Title,Description,Tag,IsDone")] Task task) { if (ModelState.IsValid) { db.Tasks.Add(task); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(task)); }
public ActionResult Create([Bind(Include = "UserId,Forename,Surname,UserName,Password")] User user) { if (ModelState.IsValid) { db.User.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public int Create(Person person) { userCreater.Create(person); return(db.SaveChanges()); //if (db.Entry<Person>(person).State == System.Data.Entity.EntityState.Added) //{ // db.SaveChangesAsync(); // return true; //} //return false; }
public ActionResult Create([Bind(Include = "Id,Name")] Project project) { if (ModelState.IsValid) { db.Projects.Add(project); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Create([Bind(Include = "Id,Name")] Member member) { if (ModelState.IsValid) { db.Members.Add(member); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(member)); }
public ActionResult Create([Bind(Include = "TaskManagerID,Name,Description,CreatedDate,UpdatedDate")] TaskManager taskManager) { if (ModelState.IsValid) { taskManager.CreatedDate = DateTime.Now; // added by Waqar Hassan on 20170926, "to set value of property" db.TaskManagers.Add(taskManager); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taskManager)); }
public ActionResult Create([Bind(Include = "StatusID,StudentsID,TasksID,status")] Status status) { if (ModelState.IsValid) { db.Status.Add(status); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentsID = new SelectList(db.Students, "StudentsID", "name", status.StudentsID); ViewBag.TasksID = new SelectList(db.Tasks, "TasksID", "name", status.TasksID); return(View(status)); }
public void Save(Curso curso) { if (curso.Id == default(int)) { _context.Cursos.Add(curso); } else { _context.Entry(curso).State = EntityState.Modified; } _context.SaveChanges(); }
public TaskDto AddNewTask(TaskDto task) { try { _context.Tasks.Add(_mapper.TaskDtoToTask(task)); _context.SaveChanges(); return(task); } catch (Exception) { throw; } }
public ActionResult Create([Bind(Include = "Id,Description,Hours,ProjectId,MemberId")] Assignment assignment) { if (ModelState.IsValid && LoadBalancer(assignment)) { //LoadBalancer(assignment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MemberId = new SelectList(db.Members, "Id", "Name", assignment.MemberId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", assignment.ProjectId); return(View(assignment)); }
public void Save(Materia materia) { if (materia.Id == default(int)) { _context.Materias.Add(materia); } else { _context.Entry(materia).State = EntityState.Modified; } _context.SaveChanges(); }
public IActionResult AddTask([Bind("Id,Description,Statuse")] TaskItem taskItem) { try { _context.TaskItems.Add(taskItem); _context.SaveChanges(); return(RedirectToAction(nameof(GetTasks))); } catch (Exception ex) { //TODO :Log ex return(View()); } }