Esempio n. 1
0
        public async void Post([FromBody] TaskViewModel task)
        {
            bool hasPermissions = 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.AddTaskAsync(model);
        }
Esempio n. 2
0
 public IActionResult Create(TaskViewModel model)
 {
     if (ModelState.IsValid)
     {
         _dataAccess.AddTaskAsync(model.ToModel(_dataAccess));
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 protected override async Task HandleCore(AddTaskCommandAsync message)
 {
     await dataAccess.AddTaskAsync(message.AllReadyTask);
 }