public BaseResponse <bool> Create(ProductPricingCreateModel model) { try { var entity = new YachtMerchantProductPricings(); entity.InjectFrom(model); entity.Deleted = false; entity.CreatedBy = GetUserGuidId(); entity.CreatedDate = DateTime.Now; entity.LastModifiedDate = DateTime.Now; entity.LastModifiedBy = GetUserGuidId(); _context.YachtMerchantProductPricings.Add(entity); _context.SaveChangesAsync().Wait(); return(BaseResponse <bool> .Success(true)); } catch (Exception ex) { return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } }
public BaseResponse <bool> CreateYachtMerchantProductInventory(YachtMerchantProductInventoryCreateModel model) { using (var tran = _context.Database.BeginTransaction()) { try { var date = DateTime.Now; var entity = new YachtMerchantProductInventories(); entity.InjectFrom(model); //Create Product entity.UniqueId = UniqueIDHelper.GenarateRandomString(12); entity.IsActiveForSales = true; entity.IsStockControl = true; entity.Deleted = false; entity.CreatedBy = GetUserGuidId(); entity.CreatedDate = date; entity.LastModifiedBy = GetUserGuidId(); entity.LastModifiedDate = date; _context.YachtMerchantProductInventories.Add(entity); _context.SaveChangesAsync().Wait(); //Create Product Price of Product if (model.Price > 0) { var entityProductPricing = new YachtMerchantProductPricings(); entityProductPricing.InjectFrom(model); entityProductPricing.ProductFid = entity.Id; entityProductPricing.Deleted = false; entityProductPricing.CreatedBy = GetUserGuidId(); entityProductPricing.CreatedDate = date; entityProductPricing.LastModifiedBy = GetUserGuidId(); entityProductPricing.LastModifiedDate = date; _context.YachtMerchantProductPricings.Add(entityProductPricing); } //Create Product Supplier of Product if (model.VendorFid > 0) { var entityProductSupplier = new YachtMerchantProductSuppliers(); entityProductSupplier.ProductFid = entity.Id; entityProductSupplier.VendorFid = model.VendorFid; entityProductSupplier.EffectiveDate = model.EffectiveDateSupplier; entityProductSupplier.EffectiveEndDate = model.EffectiveEndDateSupplier; entityProductSupplier.Remark = model.Remark; entityProductSupplier.Deleted = false; entityProductSupplier.CreatedBy = GetUserGuidId(); entityProductSupplier.CreatedDate = date; entityProductSupplier.LastModifiedBy = GetUserGuidId(); entityProductSupplier.LastModifiedDate = date; _context.YachtMerchantProductSuppliers.Add(entityProductSupplier); } //Save and Commit Transaction _context.SaveChangesAsync().Wait(); tran.Commit(); return(BaseResponse <bool> .Success(true)); } catch (Exception ex) { tran.Rollback(); return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } } }