public ActionResult DeleteConfirmed(int deleteID)
        {
            Stylist stylist_For_Deletion = _dataBase.Stylists.FirstOrDefault(iterateRowsOfStylistTable => iterateRowsOfStylistTable.StylistId == deleteID);

            _dataBase.Remove(stylist_For_Deletion);
            _dataBase.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult DeleteClient(int deleteID)
        {
            Client deletingClient = _dataBase.Clients.FirstOrDefault(rowOfClients => rowOfClients.ClientId == deleteID);

            _dataBase.Remove(deletingClient);
            _dataBase.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public void UpdateEmployeeTreatments(SalonContext context, string[] selectedTreatments, Employee employeeToUpdate)
        {
            if (selectedTreatments == null)
            {
                employeeToUpdate.TreatmentAssignments = new List <TreatmentAssignment>();
                return;
            }

            var selectedTreatmentsHS = new HashSet <string>(selectedTreatments);
            var employeeTreatments   = new HashSet <int>
                                           (employeeToUpdate.TreatmentAssignments.Select(t => t.Treatment.Id));

            foreach (var treatment in context.Treatment)
            {
                if (selectedTreatmentsHS.Contains(treatment.Id.ToString()))
                {
                    if (!employeeTreatments.Contains(treatment.Id))
                    {
                        employeeToUpdate.TreatmentAssignments.Add(
                            new TreatmentAssignment
                        {
                            TreatmentId = treatment.Id,
                            EmployeeId  = employeeToUpdate.Id
                        });
                    }
                }
                else
                {
                    if (employeeTreatments.Contains(treatment.Id))
                    {
                        TreatmentAssignment treatmentToRemove =
                            employeeToUpdate.TreatmentAssignments
                            .SingleOrDefault(i => i.TreatmentId == treatment.Id);
                        context.Remove(treatmentToRemove);
                    }
                }
            }
        }