public IHttpActionResult EditTask(TaskViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Task task = Mapper.Map <Task>(viewModel);

                _repository.EditTask(task);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult EditTask(TaskViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                Task task = Mapper.Map <Task>(viewModel);

                if (task.Id == 0)
                {
                    _repository.AddTask(task);
                }
                else
                {
                    _repository.EditTask(task);
                }

                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }