public int SubmitGallery(int UserID, WeddingGallery gallery) { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted })) { if (gallery.WeddingGalleryID == 0) { gallery.CreatedDate = DateTime.Now; gallery.CreatedBy = UserID; AccuitAdminDbContext.WeddingGalleries.Add(gallery); AccuitAdminDbContext.SaveChanges(); scope.Complete(); } else { WeddingGallery gallry = AccuitAdminDbContext.WeddingGalleries.Where(x => x.WeddingGalleryID == gallery.WeddingGalleryID).First(); gallry.ImageName = gallery.ImageName; gallry.ImageTitle = gallery.ImageTitle; gallry.ImageUrl = gallery.ImageUrl; gallry.IsDeleted = gallery.IsDeleted; gallry.Place = gallery.Place; AccuitAdminDbContext.Entry <WeddingGallery>(gallry).State = System.Data.Entity.EntityState.Modified; AccuitAdminDbContext.SaveChanges(); scope.Complete(); } } return(gallery.WeddingGalleryID); }
public int SubmitGallery(int UserID, WeddingGalleryBO galleryBO) { WeddingGallery gallery = new WeddingGallery(); ObjectMapper.Map(galleryBO, gallery); return(WeddingRepository.SubmitGallery(UserID, gallery)); }