public IHttpActionResult PostParent_Task(Parent_Task parent_Task) { db.Parent_Task.Add(parent_Task); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = parent_Task.Parent_ID }, parent_Task)); }
public IHttpActionResult PostTask(TaskDetail task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Parent_Task parent = new Parent_Task() { Parent_Task_Description = task.Parent_Description }; db.Parent_Task.Add(parent); Task taskItem = new Task() { Task_Description = task.Task, Priority = task.Priority, Start_Date = task.Start_Date, End_Date = task.End_Date }; db.Tasks.Add(taskItem); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = task.Task_ID }, task)); }
public IHttpActionResult GetParent_Task(int id) { Parent_Task parent_Task = db.Parent_Task.Find(id); return(Ok(parent_Task)); }
public IHttpActionResult PutParent_Task(int id, Parent_Task parent_Task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != parent_Task.Parent_ID) { return(BadRequest()); } db.Entry(parent_Task).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Parent_TaskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Parent_Task update method for the entities /// </summary> /// <param name="entityToUpdate"></param> public virtual int Put(int id, Parent_Task entityToUpdate) { Context.Entry(entityToUpdate).State = EntityState.Modified; return(Context.SaveChanges()); //DbSet.Attach(entityToUpdate); //Context.Entry(entityToUpdate).State = EntityState.Modified; }
public IHttpActionResult DeleteParent_Task(int id) { Parent_Task parent_Task = db.Parent_Task.Find(id); db.Parent_Task.Remove(parent_Task); db.SaveChanges(); return(Ok(parent_Task)); }
public IHttpActionResult GetParent_Task(int id) { Parent_Task parent_Task = db.Parent_Tasks.Find(id); if (parent_Task == null) { return(NotFound()); } return(Ok(parent_Task)); }
public IHttpActionResult PostParent_Task(Parent_Task parent_Task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Parent_Task.Add(parent_Task); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = parent_Task.Parent_ID }, parent_Task)); }
public IHttpActionResult PutParent_Task(int id, Parent_Task parent_Task) { if (id != parent_Task.Parent_ID) { return(BadRequest()); } //db.Entry(parent_Task).State = EntityState.Modified; db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Gets the by ID. /// </summary> /// <param name="id">The id of the ParentTask.</param> private void GetByID() { // Arrange Parent_Task ParentTask = expectedParentTasks.First(); dbSetMock.Setup(x => x.Find(It.IsAny <int>())).Returns(ParentTask); // Act _repository.GetByID(1); // Assert contextMock.Verify(x => x.Set <Parent_Task>()); dbSetMock.Verify(x => x.Find(It.IsAny <int>())); }
public IHttpActionResult DeleteParent_Task(int id) { Parent_Task parent_Task = db.Parent_Tasks.Find(id); if (parent_Task == null) { return(NotFound()); } db.Parent_Tasks.Remove(parent_Task); db.SaveChanges(); return(Ok(parent_Task)); }
public void InsertarentTask(Parent_Task task) { using (taskManagerEntities = new TaskManagerEntities()) { if (task.Parent_Task_Id == 0) { taskManagerEntities.Parent_Task.Add(task); taskManagerEntities.Entry(task).State = System.Data.Entity.EntityState.Added; } else { taskManagerEntities.Parent_Task.Add(task); taskManagerEntities.Entry(task).State = System.Data.Entity.EntityState.Modified; } taskManagerEntities.SaveChanges(); } }
public void PutParentTask() { for (int i = 0; i < numberOfThreads; i++) { // Arrange mockRepository.Setup(x => x.Post(It.IsAny <Parent_Task>())); ParentTaskController = new ParentTaskController( mockRepository.Object); ParentTaskController.Request = new HttpRequestMessage() { Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } }; // Act Parent_Task updatedParentTask = expectedParentTasks.First(); updatedParentTask.ParentTaskName = "Support and maintenance"; var response = ParentTaskController.Put(updatedParentTask.Parent_ID, updatedParentTask); _counter.Increment(); } }
public void PutParentTask() { // Arrange mockRepository.Setup(x => x.Post(It.IsAny <Parent_Task>())). Callback(() => isCreateOrUpdateInvokedInRepository = true); ParentTaskController = new ParentTaskController( mockRepository.Object); ParentTaskController.Request = new HttpRequestMessage() { Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } }; // Act Parent_Task updatedParentTask = expectedParentTasks.First(); updatedParentTask.ParentTaskName = "Support and maintenance"; var response = ParentTaskController.Put(updatedParentTask.Parent_ID, updatedParentTask); // Assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
public IHttpActionResult CreateTask(TaskModel taskModel) { if (taskModel != null) { if (taskModel.IsParentTask) { var parentTask = new Parent_Task { ParentTask = taskModel.TaskName }; parentRepository.Insert(parentTask); } else { var task = new Task { Task1 = taskModel.TaskName, ProjectID = taskModel.ProjectID, ParentID = taskModel.ParentTaskID, Priority = taskModel.Priority, StartDate = taskModel.StartDate, EndDate = taskModel.EndDate, Status = taskModel.Status }; var taskAdded = taskRepository.Insert(task); if (taskModel.UserID.HasValue) { var user = userRepository.GetAll().FirstOrDefault(x => x.UserID == taskModel.UserID); user.TaskID = taskAdded.TaskID; user.ProjectID = taskModel.ProjectID; userRepository.Insert(user); } } } return(Ok()); }
public HttpResponseMessage Post([FromBody] Parent_Task value) { return(ToJson(_parentTaskRepository.Post(value))); }
public HttpResponseMessage Put(int id, Parent_Task value) { return(ToJson(_parentTaskRepository.Put(id, value))); }
/// <summary> /// Parent_Task Insert method for the entities /// </summary> /// <param name="entity"></param> public virtual int Post(Parent_Task entity) { DbSet.Add(entity); return(Context.SaveChanges()); }