예제 #1
0
        public void Post([FromBody] ActivityViewModel value)
        {
            bool alreadyExists = _prepOpsDataAccess.GetActivity(value.Id) != null;

            if (alreadyExists)
            {
                this.HttpBadRequest();
            }
            _prepOpsDataAccess.AddActivity(value.ToModel(_prepOpsDataAccess));
        }
예제 #2
0
        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));
        }