public void Put(int id, GymClubDTO value) { GymClub model = IGymClubRepository.Get(id); if (value.Name != null) { model.Name = value.Name; } if (value.AddressId != 0) { model.AddressId = value.AddressId; } IGymClubRepository.Update(model); //trebuie sa putem face update si la lista de artisti si cantece if (value.ClassId != null) { IEnumerable <GymClubFitnessClass> MyGymClubClasses = IGymClubClassRepository.GetAll().Where(x => x.GymClubId == id); foreach (GymClubFitnessClass MyGymClubClass in MyGymClubClasses) { IGymClubClassRepository.Delete(MyGymClubClass); } for (int i = 0; i < value.ClassId.Count; i++) { GymClubFitnessClass GymClubClass = new GymClubFitnessClass() { GymClubId = model.Id, FitnessClassId = value.ClassId[i] }; IGymClubClassRepository.Create(GymClubClass); } } }
public void Post(FitnessClassDTO value) { FitnessClass model = new FitnessClass() { Name = value.Name, Img = value.Img }; IFitnessClassRepository.Create(model); // am creat o clasa // trebuie sa introducem si in tabela de intersectie for (int i = 0; i < value.InstructorId.Count; i++) { InstructorFitnessClass InstructorClass = new InstructorFitnessClass() { FitnessClassId = model.Id, InstructorId = value.InstructorId[i] }; IInstructorClassRepository.Create(InstructorClass); } for (int i = 0; i < value.GymClubId.Count; i++) { GymClubFitnessClass GymClubClass = new GymClubFitnessClass() { FitnessClassId = model.Id, GymClubId = value.GymClubId[i] }; IGymClubClassRepository.Create(GymClubClass); } }
public void Put(int id, FitnessClassDTO value) { FitnessClass model = IFitnessClassRepository.Get(id); if (value.Name != null) { model.Name = value.Name; } if (value.Img != null) { model.Img = value.Img; } IFitnessClassRepository.Update(model); //trebuie sa putem face update si la lista de instructori si sali de fitness if (value.InstructorId != null) { IEnumerable <InstructorFitnessClass> MyInstructorClasses = IInstructorClassRepository.GetAll().Where(x => x.FitnessClassId == id); foreach (InstructorFitnessClass MyInstructorClass in MyInstructorClasses) { IInstructorClassRepository.Delete(MyInstructorClass); } for (int i = 0; i < value.InstructorId.Count; i++) { InstructorFitnessClass InstructorClass = new InstructorFitnessClass() { FitnessClassId = model.Id, InstructorId = value.InstructorId[i] }; IInstructorClassRepository.Create(InstructorClass); } } if (value.GymClubId != null) { IEnumerable <GymClubFitnessClass> MyGymClubClasses = IGymClubClassRepository.GetAll().Where(x => x.FitnessClassId == id); foreach (GymClubFitnessClass MyGymClubClass in MyGymClubClasses) { IGymClubClassRepository.Delete(MyGymClubClass); } for (int i = 0; i < value.GymClubId.Count; i++) { GymClubFitnessClass GymClubClass = new GymClubFitnessClass() { FitnessClassId = model.Id, GymClubId = value.GymClubId[i] }; IGymClubClassRepository.Create(GymClubClass); } } }
public void Post(GymClubDTO value) { GymClub model = new GymClub() { Name = value.Name, AddressId = value.AddressId, }; IGymClubRepository.Create(model); // am creat un album // trebuie sa introducem si in tabela de intersectie for (int i = 0; i < value.ClassId.Count; i++) { GymClubFitnessClass GymClubClass = new GymClubFitnessClass() { GymClubId = model.Id, FitnessClassId = value.ClassId[i] }; IGymClubClassRepository.Create(GymClubClass); } }