public void Edit(Fly_Customer obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Customer .Include("Fly_Picture") .Include("Fly_Customer_CustomerRole_Mapping") .Include("Fly_CustomerAttribute") .Include("Fly_Customer_CustomerRole_Mapping.Fly_CustomerRole") .Include("Fly_Customer_CustomerRole_Mapping.Fly_CustomerRole.Fly_CustomerRole_Discount_Mapping") .Include("Fly_Customer_CustomerRole_Mapping.Fly_CustomerRole.Fly_CustomerRole_ProductPrice") .FirstOrDefault(x => x.CustomerID == obj.CustomerID); if (item != null) { var cusAtrr = item.Fly_CustomerAttribute.FirstOrDefault(); context.Entry(cusAtrr).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj.Fly_CustomerAttribute.FirstOrDefault(), cusAtrr)); context.Entry(item).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj, item)); } context.SaveChanges(); } } catch (DbEntityValidationException ex) { throw ex; } }
public bool activeAdmin(int id, bool isAdmin) { bool obj = false; try { using (var context = new flycameraEntities()) { var user = context.Fly_Customer.SingleOrDefault(x => x.CustomerID.Equals(id)); if (user != null) { user.IsAdmin = isAdmin; if (user.IsAdmin.GetValueOrDefault()) { user.IsGuest = false; } else { user.IsGuest = true; } obj = true; context.Entry(user).CurrentValues.SetValues(user); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } return(obj); }
public void Edit(Fly_SectionContent obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_SectionContent.Include("Fly_PositionGallery").Include("Fly_Product").FirstOrDefault(x => x.SectionContentID == obj.SectionContentID); if (item != null) { obj.FullDescription = (obj.FullDescription == null || obj.FullDescription.Equals(item.FullDescription)) ? item.FullDescription : obj.FullDescription; obj.FullDescription_EN = (obj.FullDescription_EN == null || obj.FullDescription_EN.Equals(item.FullDescription_EN)) ? item.FullDescription_EN : obj.FullDescription_EN; obj.PositionGalleryID = (obj.PositionGalleryID > 0 || obj.PositionGalleryID == null || obj.PositionGalleryID.Equals(item.PositionGalleryID)) ? item.PositionGalleryID : obj.PositionGalleryID; obj.ProductID = (obj.ProductID > 0 || obj.ProductID == null || obj.ProductID.Equals(item.ProductID)) ? item.ProductID : obj.ProductID; obj.CreatedOn = (obj.CreatedOn == null || obj.CreatedOn.Equals(item.CreatedOn)) ? item.CreatedOn : obj.CreatedOn; obj.UpdateOn = DateTime.Now; context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Category obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Category.Include("Fly_Category_Discount_Mapping").Include("Fly_CategoryLocalized").Where(x => x.CategoryID == obj.CategoryID).FirstOrDefault(); var mappingDiscount = item.Fly_Category_Discount_Mapping.FirstOrDefault(); var mappingLocalized = item.Fly_CategoryLocalized.FirstOrDefault(); if (item != null) { if (mappingDiscount != null) { var NewValue = obj.Fly_Category_Discount_Mapping.FirstOrDefault(); NewValue.CategoryID = (NewValue.CategoryID > 0 || NewValue.CategoryID.Equals(mappingDiscount.CategoryID)) ? mappingDiscount.CategoryID : NewValue.CategoryID; NewValue.DiscountID = (NewValue.DiscountID > 0 || NewValue.DiscountID.Equals(mappingDiscount.DiscountID)) ? mappingDiscount.DiscountID : NewValue.DiscountID; context.Entry(mappingDiscount).CurrentValues.SetValues(NewValue); } if (mappingLocalized != null) { var NewValue = obj.Fly_CategoryLocalized.FirstOrDefault(); NewValue.CategoryID = (NewValue.CategoryID == null || NewValue.CategoryID.Equals(mappingLocalized.CategoryID)) ? mappingLocalized.CategoryID : NewValue.CategoryID; NewValue.Name = (NewValue.Name == null || NewValue.Name.Equals(mappingLocalized.Name)) ? mappingLocalized.Name : NewValue.Name; context.Entry(mappingLocalized).CurrentValues.SetValues(NewValue); } context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Videos obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Videos.FirstOrDefault(x => x.VideosID == obj.VideosID); var sectionContent = context.Fly_SectionContent.FirstOrDefault(x => x.SectionContentID == obj.Fly_SectionContent.SectionContentID); if (item != null) { if (sectionContent != null) { context.Entry(sectionContent).CurrentValues.SetValues(obj.Fly_SectionContent); } context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public void Edit(Fly_Manufacturer obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Manufacturer.Include("Fly_ManufacturerLocalized").Where(x => x.ManufacturerID == obj.ManufacturerID).FirstOrDefault(); var localized = item.Fly_ManufacturerLocalized.FirstOrDefault(); if (item != null) { if (localized != null) { context.Entry(localized).CurrentValues.SetValues(obj.Fly_ManufacturerLocalized.FirstOrDefault()); } context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Customer_CustomerRole_Mapping obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Customer_CustomerRole_Mapping.FirstOrDefault(x => x.CustomerRoleID == obj.CustomerRoleID); if (item != null) { context.Entry(item).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj, item)); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Navigation obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Navigation.FirstOrDefault(x => x.navid == obj.navid); if (item != null) { context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Partnership obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Partnership.Where(x => x.PartnershipID == obj.PartnershipID).FirstOrDefault(); if (item != null) { context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Category_Discount_Mapping obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Category_Discount_Mapping.Where(x => x.CategoryID == obj.CategoryID).FirstOrDefault(); if (item != null) { context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_CustomerAttribute obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_CustomerAttribute.Where(x => x.CustomerId == obj.CustomerId).FirstOrDefault(); if (item != null) { context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Delete(int id) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Partnership.Where(x => x.PartnershipID == id).FirstOrDefault(); item.Deleted = true; if (item != null) { context.Entry(item).CurrentValues.SetValues((Fly_Partnership)item); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Delete(int id) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Videos.FirstOrDefault(x => x.VideosID == id); item.Deleted = true; if (item != null) { context.Entry(item).CurrentValues.SetValues((Fly_Videos)item); context.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public void Edit(Fly_Discount obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_Discount.FirstOrDefault(x => x.DiscountID == obj.DiscountID); if (item != null) { obj.StartDate = item.StartDate; obj.EndDate = item.EndDate; context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_SectionGallery obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_SectionGallery.Include("Fly_PositionGallery").Include("Fly_Product").FirstOrDefault(x => x.SectionGalleryID == obj.SectionGalleryID); if (item != null) { obj.BackgroundImage = (obj.BackgroundImage == null || obj.BackgroundImage.Equals(item.BackgroundImage)) ? item.BackgroundImage : obj.BackgroundImage; obj.CollectionImage = (obj.CollectionImage == null || obj.CollectionImage.Equals(item.CollectionImage)) ? item.CollectionImage : obj.CollectionImage; obj.PositionGalleryID = (obj.PositionGalleryID > 0 || obj.PositionGalleryID == null || obj.PositionGalleryID.Equals(item.PositionGalleryID)) ? item.PositionGalleryID : obj.PositionGalleryID; obj.ProductID = (obj.ProductID > 0 || obj.ProductID == null || obj.ProductID.Equals(item.ProductID)) ? item.ProductID : obj.ProductID; context.Entry(item).CurrentValues.SetValues(obj); context.SaveChanges(); } else { this.Add(obj); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_RelatedProduct obj) { try { using (var context = new flycameraEntities()) { var item = context.Fly_RelatedProduct.Find(obj.RelatedProductID); if (item != null) { context.Entry(item).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj, item)); context.SaveChanges(); } else { this.Add(obj); } } } catch (DbEntityValidationException ex) { throw ex; } }
public void Edit(Fly_Product obj) { try { using (var context = new flycameraEntities()) { var product = context.Fly_Product.Include("Fly_ProductVariant.Fly_ProductVariantLocalized") .Include("Fly_ProductVariant.Fly_ProductVariant_Discount_Mapping") .Include("Fly_ProductLocalized") .Include("Fly_Product_Category_Mapping") .Include("Fly_Product_Manufacturer_Mapping") .Include("Fly_ProductPicture.Fly_Picture") .Where(x => x.ProductId == obj.ProductId).FirstOrDefault(); // old Entity Data var mappingCate = product.Fly_Product_Category_Mapping.FirstOrDefault(); var mappingManufacturer = product.Fly_Product_Manufacturer_Mapping.FirstOrDefault(); var productLocalized = product.Fly_ProductLocalized.FirstOrDefault(); var productPicture = product.Fly_ProductPicture.FirstOrDefault(); var productVariant = product.Fly_ProductVariant.FirstOrDefault(); var mappingVariantDiscount = productVariant.Fly_ProductVariant_Discount_Mapping.FirstOrDefault(); var mappingVariantLocalized = productVariant.Fly_ProductVariantLocalized.FirstOrDefault(); // new Entity Data var productVariantNew = obj.Fly_ProductVariant.FirstOrDefault(); if (product != null) { if (mappingCate != null) { context.Entry(mappingCate).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj.Fly_Product_Category_Mapping.FirstOrDefault(), mappingCate)); } if (mappingManufacturer != null) { context.Entry(mappingManufacturer).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj.Fly_Product_Manufacturer_Mapping.FirstOrDefault(), mappingManufacturer)); } if (productLocalized != null) { context.Entry(productLocalized).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj.Fly_ProductLocalized.FirstOrDefault(), productLocalized)); } if (productPicture != null) { context.Entry(productPicture).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj.Fly_ProductPicture.FirstOrDefault(), productPicture)); } if (productVariant != null) { context.Entry(productVariant).CurrentValues.SetValues(UpdateEntities.UpdateEntity(productVariantNew, productVariant)); } if (mappingVariantLocalized != null) { context.Entry(mappingVariantLocalized).CurrentValues.SetValues(UpdateEntities.UpdateEntity(productVariantNew.Fly_ProductVariantLocalized.FirstOrDefault(), mappingVariantLocalized)); } if (mappingVariantDiscount != null) { context.Entry(mappingVariantDiscount).CurrentValues.SetValues(UpdateEntities.UpdateEntity(productVariantNew.Fly_ProductVariant_Discount_Mapping.FirstOrDefault(), mappingVariantDiscount)); } if (mappingVariantDiscount != null) { context.Entry(mappingVariantDiscount).CurrentValues.SetValues(UpdateEntities.UpdateEntity(productVariantNew.Fly_ProductVariant_Discount_Mapping.FirstOrDefault(), mappingVariantDiscount)); } context.Entry(product).CurrentValues.SetValues(UpdateEntities.UpdateEntity(obj, product)); context.SaveChanges(); } } } catch (Exception ex) { throw ex; } }