// Tạo Cineplex mới public CineplexEntity Create(UserEntity UserEntity, CineplexEntity CineplexEntity) { using (var transaction = CinemasEntities.Database.BeginTransaction()) { try { Cineplex Cineplex = new Cineplex(); Cineplex = CineplexEntity.ToModel(Cineplex); CinemasEntities.Cineplexes.Add(Cineplex); CinemasEntities.SaveChanges(); CineplexEntity.Id = Cineplex.Id; transaction.Commit(); return(GetId(UserEntity, Cineplex.Id)); } catch (Exception ex) { transaction.Rollback(); throw new BadRequestException("Không tạo được Cineplex."); } } return(null); }
public CineplexEntity Update(UserEntity UserEntity, int CinplexId, CineplexEntity CineplexEntity) { using (var transaction = CinemasEntities.Database.BeginTransaction()) { try { Cineplex Cineplex = CinemasEntities.Cineplexes.Where(c => c.Id.Equals(CineplexId)).FirstOrDefault(); if (Cineplex == null) { throw new BadRequestException("Không tìm thấy Cineplex có Id là " + CineplexId); } Cineplex = CineplexEntity.ToModel(Cineplex); CinemasEntities.SaveChanges(); transaction.Commit(); return(GetId(UserEntity, Cineplex.Id));; } catch (Exception ex) { transaction.Rollback(); throw new BadRequestException("Không cập nhật được Cineplex."); } } }
public CineplexEntity Update([FromUri] int CineplexId, [FromBody] CineplexEntity CineplexEntity) { return(CineplexService.Update(UserEntity, CineplexId, CineplexEntity)); }
public CineplexEntity Create([FromBody] CineplexEntity CineplexEntity) { return(CineplexService.Create(UserEntity, CineplexEntity)); }