Exemple #1
0
        public async void Post([FromBody] TaskViewModel task)
        {
            bool hasPermissions = await HasTaskEditPermissions(task.ToModel(_allReadyDataAccess));

            if (!hasPermissions)
            {
                HttpUnauthorized();
            }

            bool alreadyExists = _allReadyDataAccess.GetTask(task.Id) != null;

            if (alreadyExists)
            {
                HttpBadRequest();
            }

            var model = task.ToModel(_allReadyDataAccess);

            if (model == null)
            {
                HttpBadRequest("Should have found a matching activity Id");
            }

            await _allReadyDataAccess.AddTask(model);
        }
 public IActionResult Create(TaskViewModel model)
 {
     if (ModelState.IsValid)
     {
         _dataAccess.AddTask(model.ToModel(_dataAccess));
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }