public void Post([FromBody] ActivityViewModel value) { bool alreadyExists = _prepOpsDataAccess.GetActivity(value.Id) != null; if (alreadyExists) { this.HttpBadRequest(); } _prepOpsDataAccess.AddActivity(value.ToModel(_prepOpsDataAccess)); }
public async Task <IActionResult> Create(Activity activity) { var currentUser = await _userManager.GetCurrentUser(Context); if (currentUser == null || !await _userManager.IsTenantAdmin(currentUser)) { return(new HttpUnauthorizedResult()); } if (activity.TenantId != _dataAccess.GetUser(currentUser.Id).AssociatedTenant.Id) { return(new HttpUnauthorizedResult()); } if (ModelState.IsValid) { await _dataAccess.AddActivity(activity); return(RedirectToAction("Index")); } return(View(activity)); }