示例#1
0
 // 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);
 }
示例#2
0
 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.");
         }
     }
 }
示例#3
0
 public CineplexEntity Update([FromUri] int CineplexId, [FromBody] CineplexEntity CineplexEntity)
 {
     return(CineplexService.Update(UserEntity, CineplexId, CineplexEntity));
 }
示例#4
0
 public CineplexEntity Create([FromBody] CineplexEntity CineplexEntity)
 {
     return(CineplexService.Create(UserEntity, CineplexEntity));
 }