Exemple #1
0
        //  public IHttpActionResult PutToDoTask(int id,[FromBody]ToDoViewModel model)
        public IHttpActionResult PutToDoTask(int id, string title, short estimation, bool completed)
        {
            string userId = "";// User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ToDoViewModel model = new ToDoViewModel
            {
                Id         = id,
                Title      = title,
                Estimation = estimation,
                Completed  = completed
            };

            todoHub.SendUpdateTask(model.ToDtoTask());
            return(StatusCode(todoService.PutToDoTask(id, model.ToDtoTask(), userId)));
        }
Exemple #2
0
        // [Route]
        public IHttpActionResult PostToDoTask(ToDoViewModel model)
        {
            HttpStatusCode code;

            string userId = "";// User.Identity.GetUserId();

            if (model.Id == 0)
            {
                code = todoService.PostToDoTask(model.ToDtoTask(), userId);
            }

            else
            {
                code = todoService.PutToDoTask(model.Id, model.ToDtoTask(), userId);
            }
            if (code == HttpStatusCode.OK)
            {
                todoHub.SendNewTask(model.ToDtoTask());
            }
            return(StatusCode(code));
        }