示例#1
0
 public void Update(DtoToDoTask entity)
 {
     // validation
     // commit changes to database
     service.PutToDoTask(entity.Id.Value, entity, "");
     Clients.Others.update(entity);
 }
示例#2
0
 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));
        }
示例#4
0
 //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();
     }
 }
示例#5
0
        //   [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()));
        }
示例#6
0
        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));
        }
示例#7
0
 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));
        }
示例#9
0
 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();
     }
 }
示例#10
0
        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));
        }