public int UpdatePlay(PlayWithActors playDTO) { using (var _unitOfWork = UnitOfWork.GetUnitOfWork()) { var play = _unitOfWork.PlayRepository.GetById(playDTO.Id); play.Title = playDTO.Title; play.ImagePath = playDTO.ImagePath; play.ImageVirtualPath = playDTO.ImageVirtualPath; play.ImageType = playDTO.ImageType; play.Description = playDTO.Description; play.ScheduledTime = playDTO.ScheduledTime; var playActorRecords = _unitOfWork.PlayActorRepository.GetPlayActorsForPlayId(play.Id); foreach (var playActorRecord in playActorRecords) { _unitOfWork.PlayActorRepository.Delete(playActorRecord.Id); } foreach (var id in playDTO.ActorsIds) { PlayActor playActor = new PlayActor { PlayId = play.Id, ActorId = id }; _unitOfWork.PlayActorRepository.Insert(playActor); } _unitOfWork.Save(); return(play.Id); } }
public int CreatePlay(PlayWithActors playDTO) { using (var _unitOfWork = UnitOfWork.GetUnitOfWork()) { Play play = new Play { Title = playDTO.Title, ImagePath = playDTO.ImagePath, ImageVirtualPath = playDTO.ImageVirtualPath, ImageType = playDTO.ImageType, Description = playDTO.Description, ScheduledTime = playDTO.ScheduledTime }; _unitOfWork.PlayRepository.Insert(play); foreach (var id in playDTO.ActorsIds) { PlayActor playActor = new PlayActor { PlayId = play.Id, ActorId = id }; _unitOfWork.PlayActorRepository.Insert(playActor); } _unitOfWork.Save(); return(play.Id); } }
public void InsertRecord(PlayActor entity) { using (var _unitOfWork = UnitOfWork.GetUnitOfWork()) { _unitOfWork.PlayActorRepository.Insert(entity); _unitOfWork.Save(); } }
public void Delete(int id) { PlayActor playActor = context.PlayActors.Find(id); if (playActor != null) { context.PlayActors.Remove(playActor); } }
public void Insert(PlayActor playActorRecord) { context.PlayActors.Add(playActorRecord); }