public void Update(DtoToDoTask entity) { // validation // commit changes to database service.PutToDoTask(entity.Id.Value, entity, ""); Clients.Others.update(entity); }
public void Destroy(DtoToDoTask entity) { // validation // commit changes to database service.DeleteToDoTask(entity.Id.Value, ""); Clients.Others.destroy(entity); }
public IHttpActionResult GetDtoToDoTask(int id) { DtoToDoTask dtoToDoTask = todoService.GetToDoTask(id, ""); if (dtoToDoTask == null) { return(NotFound()); } return(Ok(dtoToDoTask)); }
//Specific User Call public void SendNewTask(DtoToDoTask task) { try { var context = GlobalHost.ConnectionManager.GetHubContext <ToDoTasksHub>(); context.Clients.All.create(task); } catch (Exception ex) { ex.ToString(); } }
// [Route] public IHttpActionResult GetToDoTask(int id) { string userId = "";// User.Identity.GetUserId(); DtoToDoTask toDoTask = todoService.GetToDoTask(id, userId); if (toDoTask == null) { return(NotFound()); } return(Ok(toDoTask.ToTaskViewModel())); }
public IHttpActionResult DeleteToDoTask(int id) { string userId = "";// User.Identity.GetUserId(); DtoToDoTask task = todoService.GetToDoTask(id, ""); HttpStatusCode code = todoService.DeleteToDoTask(id, userId); if (code == HttpStatusCode.NoContent) { todoHub.SendDeleteTask(task); } return(StatusCode(code)); }
public static ToDoViewModel ToTaskViewModel(this DtoToDoTask task) { return(new ToDoViewModel { Id = task.Id.HasValue?task.Id.Value:0, CreatedFor = task.CreatedFor, CreatedByName = task.CreatedBy, Estimation = task.Estimation, Completed = task.Completed, Title = task.Title }); }
public IHttpActionResult PostDtoToDoTask(DtoToDoTask dtoToDoTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } HttpStatusCode code = todoService.PostToDoTask(dtoToDoTask, ""); todoHub.SendNewTask(dtoToDoTask); return(CreatedAtRoute("DefaultApi", new { id = dtoToDoTask.Id }, dtoToDoTask)); }
public void SendUpdateTask(DtoToDoTask task) { try { var context = GlobalHost.ConnectionManager.GetHubContext <ToDoTasksHub>(); context.Clients.All.update(task); context.Clients.All.Invoke("Update", new DataSourceResult { Data = new[] { task } }); } catch (Exception ex) { ex.ToString(); } }
public DtoToDoTask Create(DtoToDoTask entity) { // validation // commit changes to database service.PostToDoTask(entity, ""); if (entity.Id > 0) { Clients.Others.update(entity); } else { Clients.Others.create(entity); } return(entity); }
public IHttpActionResult PutDtoToDoTask(DtoToDoTask dtoToDoTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } /* if (id != dtoToDoTask.Id) * { * return BadRequest(); * }*/ HttpStatusCode code = todoService.PutToDoTask(dtoToDoTask.Id.Value, dtoToDoTask, ""); todoHub.SendUpdateTask(dtoToDoTask); return(StatusCode(code)); }