public HttpStatusCode PutToDoTask(int id, DtoToDoTask model, string userId) { //ignoring userid- anybody can get ToDoTask toDoTask = GetTask(id, userId); if (toDoTask == null) { return(HttpStatusCode.NotFound); } //toDoTask.CreatedFor = model.CreatedFor; toDoTask.Title = model.Title; toDoTask.EstimatedHours = model.Estimation; toDoTask.Completed = model.Completed; db.Entry(toDoTask).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(HttpStatusCode.BadRequest); } return(HttpStatusCode.OK); }
public HttpStatusCode PostToDoTask(DtoToDoTask model, string userId) { var users = db.AspNetUsers.ToList(); Random random = new Random(); int index = random.Next(0, users.Count); var createdby = users[index]; if (createdby == null) { return(HttpStatusCode.NotFound); } ToDoTask toDoTask = new ToDoTask { CreatedBy = createdby.Name, CreatedTime = DateTime.Now, Title = model.Title, Completed = false, EstimatedHours = model.Estimation }; db.ToDoTasks.Add(toDoTask); db.SaveChanges(); return(HttpStatusCode.OK); }
public HttpStatusCode DeleteToDoTask(DtoToDoTask task, string userid) { return(DeleteToDoTask(task.Id.Value, "")); }