コード例 #1
0
        public async Task <IActionResult> Create([Bind("BlogId,Title,AppUserId")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            SelectList selectList = new SelectList(_context.AppUsers, "Id", "UserName", blog.AppUserId);

            ViewData["AppUserId"] = selectList;
            return(View(blog));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,SoupCount")] SoupFrequency soupFrequency)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(soupFrequency));
            }
            if (ModelState.IsValid)
            {
                var checkExit = _context.SoupFrequency.Where(x => x.SoupCount == soupFrequency.SoupCount).Count();

                if (checkExit == 0)
                {
                    _context.Add(soupFrequency);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);
                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(soupFrequency));
        }
コード例 #3
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,UserId,UserSwallowId")] UserSwallowSelection userSwallowsSelection, int grainselect)
        {
            AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);

            userSwallowsSelection.UserId = user.Id;
            //userSwallowsSelection.UserSwallowsId = grainselect;
            if (userSwallowsSelection.Id >= 0 & userSwallowsSelection.UserId != null & userSwallowsSelection.UserSwallowId != 0)
            {
                var item = await _context.UserSwallowSelection.Where(x => x.UserId == user.Id).FirstOrDefaultAsync(x => x.UserSwallowId == userSwallowsSelection.UserSwallowId);

                if (item == null)
                {
                    _context.Add(userSwallowsSelection);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    // ModelState.AddModelError("", "Swallows alreay exist");
                    var errorMessage = "Swallows alreay exist";
                    //return RedirectToAction(nameof(Create));
                    return(RedirectToAction("Index", new { message = errorMessage }));
                }
            }
            return(View(userSwallowsSelection));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,LightFoodName,LightFoodMainIngredient")]
                                                 LightFoodNutrient lightFoodNutrient, int lightfoodmain, int lightfoodas)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(lightfoodmain));
            }
            if (ModelState.IsValid)
            {
                var checkExist = _context.LightFoodNutrient.Where(x => x.LightFoodName == lightfoodas).Where(x => x.LightFoodMainIngredient != 0).Count();
                if (checkExist == 0)
                {
                    lightFoodNutrient.LightFoodName           = lightfoodas;
                    lightFoodNutrient.LightFoodMainIngredient = lightfoodmain;
                    _context.Add(lightFoodNutrient);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddSuccessToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);

                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lightFoodNutrient));
        }
コード例 #5
0
ファイル: IdentityTests.cs プロジェクト: nightBaker/TestHouse
        public void CreateUser()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();
            try
            {
                var options = new DbContextOptionsBuilder <AppIdentityDbContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new AppIdentityDbContext(options))
                {
                    context.Database.EnsureCreated();
                    var user = new ApplicationUser();
                    context.Add(user);
                    context.SaveChanges();
                    Assert.NotEmpty(context.Users);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
コード例 #6
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,UserId,UserGrainDishId")] UserGrainDishSelection userGrainDishesSelection, int grainselect)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                return(new JsonResult(new { status = 0, message = msg }));
            }

            AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);

            var checkfood = _context.UserGrainDishSelection.Where(x => x.UserId == user.Id && x.UserGrainDishId == userGrainDishesSelection.UserGrainDishId).ToList().Count();

            if (checkfood == 0)
            {
                userGrainDishesSelection.UserId = user.Id;
                _context.Add(userGrainDishesSelection);
                await _context.SaveChangesAsync();

                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);
                var errorMessage = "GrainDishes alreay exist";
                //return RedirectToAction(nameof(Create));
                return(RedirectToAction("Index", new { message = errorMessage }));
            }
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,SwallowName,MainIngredientsId")] SwallowNutrient swallowNutrient
                                                 , int ingswallowings, int ingredient)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(swallowNutrient));
            }
            if (ModelState.IsValid)
            {
                var checkExist = _context.SwallowNutrient.Where(x => x.SwallowName == ingswallowings).Where(x => x.MainIngredientsId != 0).Count();
                if (checkExist == 0)
                {
                    swallowNutrient.SwallowName       = ingswallowings;
                    swallowNutrient.MainIngredientsId = ingredient;
                    _context.Add(swallowNutrient);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddSuccessToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);

                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(swallowNutrient));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,Name,ClassOfFood")] MainIngredient mainIngredient)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(mainIngredient));
            }
            if (ModelState.IsValid)
            {
                var checkExit = _context.MainIngredient.Where(x => x.Name.ToLower() == mainIngredient.Name.ToLower()).Count();

                if (checkExit == 0)
                {
                    _context.Add(mainIngredient);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddSuccessToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);
                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainIngredient));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("Id,GrainName,SoupRequired,KaroMainIngredientsId")]
                                                 GrainDishNutrient grainDishNutrient, int karoingredient, int grainselect, bool soupRequired)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(karoingredient));
            }
            if (ModelState.IsValid)
            {
                var checkExist = _context.GrainDishNutrient.Where(x => x.GrainName == grainselect).Where(x => x.KaroMainIngredientsId != 0).Count();
                if (checkExist == 0)
                {
                    grainDishNutrient.GrainName             = grainselect;
                    grainDishNutrient.KaroMainIngredientsId = karoingredient;
                    _context.Add(grainDishNutrient);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddSuccessToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);

                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(grainDishNutrient));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("Id,StudentId,LastName,FirstName,MiddleName,Email,Address")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                var studentId = student.Id;
                var grade     = new Grade
                {
                    Prelim_Assign1   = 0,
                    Prelim_Assign2   = 0,
                    Prelim_Assign3   = 0,
                    Prelim_Quiz1     = 0,
                    Prelim_Quiz2     = 0,
                    Prelim_Quiz3     = 0,
                    Midterm_Assign1  = 0,
                    Midterm_Assign2  = 0,
                    Midterm_Assign3  = 0,
                    Midterm_Quiz1    = 0,
                    Midterm_Quiz2    = 0,
                    Midterm_Quiz3    = 0,
                    Prefinal_Assign1 = 0,
                    Prefinal_Assign2 = 0,
                    Prefinal_Assign3 = 0,
                    Prefinal_Quiz1   = 0,
                    Prefinal_Quiz2   = 0,
                    Prefinal_Quiz3   = 0,
                    Final_Assign1    = 0,
                    Final_Assign2    = 0,
                    Final_Assign3    = 0,
                    Final_Quiz1      = 0,
                    Final_Quiz2      = 0,
                    Final_Quiz3      = 0,
                    StudentID        = studentId
                };

                _context.Add <Grade>(grade);
                _context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("ID,Type,Id,Name,NormalizedName,ConcurrencyStamp")] Roles roles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(roles));
        }
コード例 #12
0
        public async Task <IActionResult> Create([Bind("Id,Question,Answer")] FAQs fAQs)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fAQs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fAQs));
        }
コード例 #13
0
        public async Task <IActionResult> Create([Bind("ID,Brand,Plate,Model,Capacity,MaintenanceSituation")] Vehicles vehicles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicles));
        }
コード例 #14
0
        public async Task <IActionResult> Create([Bind("DepartmentId,DepartmentName")] UserDepartment userDepartment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userDepartment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/AppIdentity/Views/UserDepartment/CreateEdit.cshtml", userDepartment));
        }
コード例 #15
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName")] CrmPersonnel crmPersonnel)
        {
            if (!ModelState.IsValid)
            {
                return(View(crmPersonnel));
            }
            _context.Add(crmPersonnel);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #16
0
        public async Task <IActionResult> Create([Bind("ID,Name,UserID,DepartGarageID,ArrivalGarageID,DriverID,VehicleID,BeginTime,EndTime,IsActive")] Expeditions expeditions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(expeditions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(expeditions));
        }
コード例 #17
0
        public async Task <IActionResult> Create([Bind("ID,Name,CityID,Address,Coord_X,Coord_Y,Convenience")] Garages garages)
        {
            if (ModelState.IsValid)
            {
                _context.Add(garages);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(garages));
        }
コード例 #18
0
        public async Task <IActionResult> Create([Bind("Id,CountryName")] Country country)
        {
            if (ModelState.IsValid)
            {
                country.Id = Guid.NewGuid();
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
コード例 #19
0
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Body")] Contactus contactus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contactus);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(Redirect("/"));
            }
            return(View(contactus));
        }
コード例 #20
0
        public async Task <IActionResult> Create([Bind("Id,Title")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(category));
        }
コード例 #21
0
        public async Task <IActionResult> Create([Bind("Id,SwallowSoupId")] SwallowSoup swallowSoup, int grainselect)
        {
            swallowSoup.SwallowSoupId = grainselect;
            if (ModelState.IsValid)
            {
                _context.Add(swallowSoup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(swallowSoup));
        }
コード例 #22
0
        public async Task <IActionResult> Create([Bind("BranchDetialId,BranchId,HouseNumber")] UserBranchDetial userBranchDetial)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userBranchDetial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { id = userBranchDetial.BranchId }));
            }
            ViewData["BranchId"] = new SelectList(_context.UserBranch, "BranchId", "BranchName", userBranchDetial.BranchId);
            return(PartialView("~/Areas/AppIdentity/Views/UserBranchDetial/CreateEdit.cshtml", userBranchDetial));
        }
コード例 #23
0
        public async Task <IActionResult> Create([Bind("Id,Prelim_Quiz1,Prelim_Quiz2,Prelim_Quiz3,Prelim_Assign1,Prelim_Assign2,Prelim_Assign3,Midterm_Quiz1,Midterm_Quiz2,Midterm_Quiz3,Midterm_Assign1,Midterm_Assign2,Midterm_Assign3,Prefinal_Quiz1,Prefinal_Quiz2,Prefinal_Quiz3,Prefinal_Assign1,Prefinal_Assign2,Prefinal_Assign3,Final_Quiz1,Final_Quiz2,Final_Quiz3,Final_Assign1,Final_Assign2,Final_Assign3,StudentID")] Grade grade)
        {
            System.Diagnostics.Debug.WriteLine(grade.StudentID);
            if (ModelState.IsValid)
            {
                _context.Add(grade);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            StudentsDropdownList(grade.StudentID);
            return(View(grade));
        }
コード例 #24
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,DueDate,CategoryId")]
                                                 Feature feature)
        {
            if (ModelState.IsValid)
            {
                feature.CreatedAt = DateTime.Now;
                feature.VoteCount = 0;
                _context.Add(feature);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(Create());
        }
コード例 #25
0
        public IActionResult Create(Question question)
        {
            if (ModelState.IsValid)
            {
                Question quest = new Question
                {
                    Name       = question.Name,
                    Profession = question.Profession,
                    Age        = question.Age
                };

                context.Questions.Attach(quest);
                context.Add(quest);
                context.SaveChanges();


                return(RedirectToAction("Thanks"));
            }
            return(View(question));
        }
コード例 #26
0
        public async Task <IActionResult> Create(CreateBook newBook)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Author author = new Author
                    {
                        Name        = newBook.Name,
                        Description = newBook.Description
                    };

                    Book book = new Book
                    {
                        ISBN          = newBook.ISBN,
                        Title         = newBook.Title,
                        Language      = newBook.Language,
                        NumberOfPages = newBook.NumberOfPages,
                        Authors       = new List <Author>()
                    };

                    book.Authors.Add(author);

                    _context.Add(book);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Book"));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator." + ex.Message);
            }
            return(RedirectToAction("Index"));
        }
コード例 #27
0
        public async Task <IActionResult> Upvote(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var feature = await _context.Feature.FindAsync(id);

            if (feature == null)
            {
                return(NotFound());
            }
// Check features -> users() exists

            var userId    = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var userVotes = from uv in _context.UserVote select uv;
            var exists    = userVotes
                            .Where(uv => uv.FeatureId == id)
                            .Any(u => u.UserId == userId);

            if (!exists)
            {
                feature.VoteCount++;
                var userVote = new UserVote
                {
                    FeatureId = feature.Id,
                    UserId    = userId,
                    CreatedAt = DateTime.Now
                };
                _context.Add(userVote);
                _context.Update(feature);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Index)));
        }
コード例 #28
0
        public async Task <IActionResult> Create([Bind("Id,AccountNumber,Password,Alive")] AspNetUserForexAccount frxUserAccount)
        {
            if (ModelState.IsValid)
            {
                AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name);

                frxUserAccount.AppIdentityUserId = _user.Id;
                _identitycontext.Add(frxUserAccount);
                await _identitycontext.SaveChangesAsync();

                if (frxUserAccount.Alive == true)
                {
                    var temp = _identitycontext.AspNetUserForexAccount.Where(x => x.AppIdentityUserId == _user.Id && x.AccountNumber != frxUserAccount.AccountNumber).ToList();
                    foreach (var t in temp)
                    {
                        t.Alive = false;
                    }
                    _identitycontext.UpdateRange(temp);
                    await _identitycontext.SaveChangesAsync();
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/Forex/Views/FrxUserAccount/CreateEdit.cshtml", frxUserAccount));
        }
コード例 #29
0
 public ServiceResult Create(TEntity entity)
 {
     _context.Add(entity);
     return(Save());
 }
コード例 #30
0
            public async Task <bool> Handle(AutoCreateShiftsCommand request, CancellationToken cancellationToken)
            {
                DateTime startDate = request.StartDate;
                DateTime endDate   = request.EndDate;

                // create shift type Ids in the roaster sequence for automated shift
                List <int> orderedShiftTypeIds = await _context.ShiftCycleItems.OrderBy(sci => sci.ShiftSequence).Select(sci => sci.ShiftTypeId).ToListAsync();

                // List<ShiftType> shiftTypes = await _context.ShiftTypes.OrderBy(st => st.RoasterSequence).ToListAsync();
                // List<int> orderedShiftTypeIds_old = shiftTypes.Select(st => st.ShiftTypeId).ToList();

                //Func<int, int, Tuple<int, int>> GetNextShiftTypeInfo = (currentShiftTypeId, numTimesAlreadyOccured) =>
                //{
                //    if (numTimesAlreadyOccured == 1)
                //    {
                //        return new Tuple<int, int>(currentShiftTypeId, 2);
                //    }
                //    int nextShiftTypeId = -1;
                //    int updatedAlreadyOccured = -1;
                //    if (orderedShiftTypeIds.Any(sti => sti == currentShiftTypeId))
                //    {
                //        int currentShiftTypeIdIndex = orderedShiftTypeIds.FindIndex(sti => sti == currentShiftTypeId);
                //        int nextShiftTypeIdIndex = currentShiftTypeIdIndex + 1;
                //        if (nextShiftTypeIdIndex >= orderedShiftTypeIds.Count)
                //        {
                //            nextShiftTypeIdIndex = 0;
                //        }
                //        nextShiftTypeId = orderedShiftTypeIds[nextShiftTypeIdIndex];
                //        updatedAlreadyOccured = 1;
                //    }
                //    return new Tuple<int, int>(nextShiftTypeId, updatedAlreadyOccured);
                //};

                // using local function
                int GetNextShiftTypeIndex(int currentShiftTypeIndex)
                {
                    int nextShiftTypeIndex = -1;

                    if (currentShiftTypeIndex < 0)
                    {
                        return(-1);
                    }
                    if (currentShiftTypeIndex == orderedShiftTypeIds.Count - 1)
                    {
                        nextShiftTypeIndex = 0;
                    }
                    else
                    {
                        nextShiftTypeIndex = currentShiftTypeIndex + 1;
                    }
                    return(nextShiftTypeIndex);
                }

                // get the shifts on the start Date
                List <Shift> startDayShifts = await _context.Shifts.Include(s => s.ShiftType).Include(s => s.ShiftParticipations).Where(s => s.ShiftDate == startDate).ToListAsync();

                // iterate through each shift in the start date
                foreach (Shift startDayShift in startDayShifts)
                {
                    List <ShiftParticipation> startDayShiftParticipations = startDayShift.ShiftParticipations.ToList();
                    int currentShiftTypeId    = startDayShift.ShiftTypeId;
                    int currentShiftTypeIndex = orderedShiftTypeIds.IndexOf(currentShiftTypeId);

                    // iterate through each shift date for automation
                    for (DateTime shiftDate = startDate.AddDays(1); (shiftDate.Date <= endDate.Date) && (currentShiftTypeIndex != -1); shiftDate = shiftDate.AddDays(1))
                    {
                        // get the next ShiftType in the shift cycle sequence creating the new shift
                        currentShiftTypeIndex = GetNextShiftTypeIndex(currentShiftTypeIndex);
                        currentShiftTypeId    = orderedShiftTypeIds[currentShiftTypeIndex];

                        // delete all the shifts of the particular shift type on that day if present
                        List <Shift> existingShifts = await _context.Shifts.Where(s => s.ShiftDate == shiftDate && s.ShiftTypeId == currentShiftTypeId).ToListAsync();

                        foreach (Shift existingShift in existingShifts)
                        {
                            _context.Shifts.Remove(existingShift);
                        }

                        // create new shift with the shift participations
                        Shift newShift = new Shift {
                            ShiftTypeId = currentShiftTypeId, ShiftDate = shiftDate
                        };
                        _context.Add(newShift);
                        await _context.SaveChangesAsync();

                        // create the shift participations for the new shift
                        foreach (ShiftParticipation shiftPart in startDayShift.ShiftParticipations)
                        {
                            ShiftParticipation newShiftPart = new ShiftParticipation {
                                ShiftId = newShift.Id, EmployeeId = shiftPart.EmployeeId, ParticipationSequence = shiftPart.ParticipationSequence, ShiftParticipationTypeId = shiftPart.ShiftParticipationTypeId
                            };
                            _context.ShiftParticipations.Add(newShiftPart);
                            await _context.SaveChangesAsync();
                        }
                    }
                }
                return(true);
            }