public void Post([FromBody] ActivityViewModel value)
        {
            bool alreadyExists = _allReadyDataAccess.GetActivity(value.Id) != null;

            if (alreadyExists)
            {
                this.HttpBadRequest();
            }
            _allReadyDataAccess.AddActivity(value.ToModel(_allReadyDataAccess));
        }
示例#2
0
        public async Task <IActionResult> Create(Activity activity)
        {
            if (activity.TenantId != User.GetTenantId())
            {
                return(new HttpUnauthorizedResult());
            }

            if (ModelState.IsValid)
            {
                await _dataAccess.AddActivity(activity);

                return(RedirectToAction("Index"));
            }
            return(View(activity));
        }
        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));
        }