public IActionResult UpdateYachtMerchantProductPricing(ProductPricingCreateOrUpdateModel model) { var res = _yachtMerchantProductInventoryService.UpdateProductPricing(model); if (res.IsSuccessStatusCode) { return(Ok(res)); } return(BadRequest()); }
public BaseResponse <bool> CreateProductPricing(ProductPricingCreateOrUpdateModel model) { try { var products = _context.YachtMerchantProductPricings.Where(x => x.ProductFid == model.ProductFid && !x.Deleted && x.EffectiveEndDate > DateTime.Now.Date).ToList(); if (products.Count > 0) { var supplierLast = products[products.Count - 1]; var isExistedInfo = false; isExistedInfo = CheckdDateTimeInsert(model.EffectiveDate, model.EffectiveEndDate, supplierLast.EffectiveDate, supplierLast.EffectiveEndDate); if (!isExistedInfo) { return(BaseResponse <bool> .NotFound(false)); } } if (model.EffectiveEndDate.HasValue) { if (model.EffectiveDate.Date >= model.EffectiveEndDate.Value.Date) { return(BaseResponse <bool> .BadRequest(false)); } } var entity = new YachtMerchantProductPricings(); entity.ProductFid = model.ProductFid; entity.EffectiveDate = model.EffectiveDate; entity.EffectiveEndDate = model.EffectiveEndDate; entity.Price = model.Price; entity.CultureCode = model.CultureCode; entity.CurrencyCode = model.CurrencyCode; 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> UpdateProductPricing(ProductPricingCreateOrUpdateModel model) { try { var entity = _context.YachtMerchantProductPricings.FirstOrDefault(x => x.Id == model.Id); if (entity != null) { entity.EffectiveEndDate = model.EffectiveEndDate; entity.Price = model.Price; entity.CultureCode = model.CultureCode == null ? entity.CultureCode : model.CultureCode; entity.CurrencyCode = model.CurrencyCode == null ? entity.CurrencyCode : model.CurrencyCode; entity.LastModifiedDate = DateTime.Now; entity.LastModifiedBy = GetUserGuidId(); _context.YachtMerchantProductPricings.Update(entity); _context.SaveChangesAsync().Wait(); return(BaseResponse <bool> .Success(true)); } return(BaseResponse <bool> .NotFound(false)); } catch (Exception ex) { return(BaseResponse <bool> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace)); } }