Esempio n. 1
0
 public IActionResult Create(TaskViewModel model) {
     if (ModelState.IsValid) {
         _dataAccess.AddTask(model.ToModel(_dataAccess));
         return RedirectToAction("Index");
     }
     return View(model);
 }
Esempio n. 2
0
        public async void Post([FromBody] TaskViewModel task)
        {
            bool hasPermissions = await HasTaskEditPermissions(task.ToModel(_prepOpsDataAccess));

            if (!hasPermissions)
            {
                HttpUnauthorized();
            }

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

            if (alreadyExists)
            {
                HttpBadRequest();
            }

            var model = task.ToModel(_prepOpsDataAccess);

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

            await _prepOpsDataAccess.AddTask(model);
        }