示例#1
0
        public async Task <IActionResult> Schedule(CreateShiftInputModel input)
        {
            var businessId   = this.HttpContext.Items[GlobalConstants.BusinessIdSessionName].ToString();
            var userId       = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var managementId = await this.employeeGroupService.GetFirstEmployeeIdFromAdministrationGroups(userId, businessId);

            if (!this.ModelState.IsValid)
            {
                var groups = await this.groupService.GetAllGroupsByBusiness <GroupAllViewModel>(input.BusinessId, false);

                input.Groups = groups;
                return(this.View(input));
            }

            await this.shiftService.CreateShiftAsync(managementId, input.GroupId, input.Start, input.End, input.Description, input.BonusPayment ?? 0);

            this.TempData["GroupId"] = input.GroupId;
            return(this.RedirectToAction("Schedule", new { input.BusinessId }));
        }
示例#2
0
        public async Task <IActionResult> Schedule()
        {
            var businessId = this.HttpContext.Items[GlobalConstants.BusinessIdSessionName].ToString();

            var groups = await this.groupService.GetAllGroupsByBusiness <GroupAllViewModel>(businessId, false);

            if (groups.Count() == 0)
            {
                return(this.View("NoAvailableGroups"));
            }

            var viewModel = new CreateShiftInputModel()
            {
                BusinessId = businessId,
                Groups     = groups,
            };

            this.TempData["GroupId"] = groups.First().Id;

            return(this.View(viewModel));
        }