public Boolean AddPriceLog(PriceLog precio) { _precios.Add(precio.priceLog_id, precio); return(true); //throw new NotImplementedException(); }
public void DeletePriceLogRs(int Id) { PriceLog deletePriceLogRs = GetPriceLogById(Id); deletePriceLogRs.IsDeleted = true; UpdatePriceLog(deletePriceLogRs); }
public void DeletePriceLog(int Id) { PriceLog deletedPriceLog = GetPriceLogById(Id); Context.PriceLog.Remove(deletedPriceLog); Context.Entry(deletedPriceLog).State = EntityState.Deleted; Context.SaveChanges(); }
private PriceLog ToPricelogInfo(PriceLog model) { return(new PriceLog { PriceLogid = model.PriceLogid, Productid = model.Productid, NewPrice = model.NewPrice, UserId = model.UserId, Pricechangedate = model.Pricechangedate }); }
public async Task <PriceEditOutput> ExecuteReplaceWithExisiting(PriceEditInput input) { var price = await this._priceRepository.GetEntityAsync(e => e.Id == input.PriceId.Value); if (price != null) { if (input.PartInstanceId.HasValue) { var partInstance = await this._partInstanceRepository.GetEntityAsync(e => e.Id == input.PartInstanceId.Value); if (partInstance != null) { var priceLog = new PriceLog(partInstance, price); var currentPriceLog = partInstance.PriceLogs.FirstOrDefault(e => e.IsCurrent); if (currentPriceLog != null) { currentPriceLog.IsCurrent = false; await this._priceLogRepository.UpdateAsync(currentPriceLog); } partInstance.UpdatePrice(price.Id, price.UnitCost); await this._priceLogRepository.AddAsync(priceLog); await this._partInstanceRepository.UpdateAsync(partInstance); } else { return(new PriceEditOutput(null, false, "Error: PartInstance Not Found")); } } else { return(new PriceEditOutput(null, false, "Error: PartInstance Not Found")); } var updated = await this._priceRepository.UpdateAsync(price); if (updated != null) { var count = await this._unitOfWork.Save(); return(new PriceEditOutput(updated, true, "Price Changes Saved")); } else { await this._unitOfWork.Undo(); return(new PriceEditOutput(null, false, "Price Save Failed")); } } else { return(new PriceEditOutput(null, false, "Error: Price Not Found")); } }
public void CreateProdeLog(Product Product) { var PriceLog = new PriceLog(); PriceLog.IsDeleted = false; PriceLog.CreatedUserId = WebSecurity.CurrentUserId; PriceLog.ModifiedUserId = WebSecurity.CurrentUserId; PriceLog.CreatedDate = DateTime.Now; PriceLog.ModifiedDate = DateTime.Now; PriceLog.ProductId = Product.Id; PriceLog.PriceInbound = Product.PriceInbound; PriceLog.PriceOutbound = Product.PriceOutbound; PriceLog.StartDateApply = DateTime.Now; ProductRepository.InsertPriceLog(PriceLog); }
public async Task <IActionResult> PutProductsPrice(int id, decimal productsPrice) { var identity = HttpContext.User.Identity as ClaimsIdentity; bool canContinue = await IdentifyAdminLoginAsync(identity); if (canContinue) { LogedUser = identity.FindFirst(ClaimTypes.NameIdentifier).Value.ToString(); var products = await _context.Products.FindAsync(id); products.ProductPrice = productsPrice; if (id != products.ProductId) { return(BadRequest()); } _context.Entry(products).State = EntityState.Modified; try { var PriceLog = new PriceLog { Productid = products.ProductId, NewPrice = products.ProductPrice, Pricechangedate = DateTime.UtcNow, UserId = LogedUser }; _context.PriceLog.Add(PriceLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); } return(NotFound()); }
public Boolean UpdatePrice(int product_id, float price, IPriceLogServices _precios) { PriceLog precios = new PriceLog(); float price_old; price_old = _products[product_id].price_product; _products[product_id].price_product = price; //Construir objeto para registrar bitacora //precios.priceLog_id = 1; precios.priceLog_id = _precios.IdMaximo(); precios.price_current = price; precios.price_old = price_old; precios.product_id = product_id; precios.price_updated = DateTime.Now; //Añadir bitacora return(_precios.AddPriceLog(precios)); }
public async Task <CheckInOutput> ExecuteNewPrice(CheckInInput input) { var part = await this._partRepository.GetEntityAsync(e => e.Id == input.PartId); if (part != null) { input.PartInstance.PartId = input.PartId; input.PartInstance.Price = input.Price; input.PartInstance.UpdatePrice(); var instanceEntity = await this._partInstanceRepository.AddAsync(input.PartInstance); if (instanceEntity != null) { PartPrice partPrice = new PartPrice(part, instanceEntity.Price); PriceLog priceLog = new PriceLog(instanceEntity, instanceEntity.Price); await this._partPriceRepository.AddAsync(partPrice); await this._priceLogRepository.AddAsync(priceLog); Transaction transaction = new Transaction(); transaction.SetupCheckIn(instanceEntity, InventoryAction.INCOMING, instanceEntity.LocationId, input.TimeStamp); transaction.SessionId = this._userService.CurrentSessionId.Value; var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == instanceEntity.StockTypeId); if (stockType != null) { if (!stockType.IsDefault) { if (stockType != null) { if (instanceEntity.IsBubbler) { stockType.Quantity += (int)instanceEntity.BubblerParameter.Weight; } else { stockType.Quantity += instanceEntity.Quantity; } await this._categoryRepository.UpdateAsync(stockType); } } else { IndividualAlert alert = new IndividualAlert(); alert.PartInstance = instanceEntity; instanceEntity.IndividualAlert = alert; this._context.Add(alert); } } else { await this._unitOfWork.Undo(); return(new CheckInOutput(null, false, "Error: Could not adjust stock, Please contact administrator")); } var tranEntity = await this._transactionRepository.AddAsync(transaction); var count = await this._unitOfWork.Save(); if (count > 0) { return(new CheckInOutput(instanceEntity, true, "Part Checked In!")); } else { await this._unitOfWork.Undo(); return(new CheckInOutput(null, false, "Error: Check in Failed")); } } else { await this._unitOfWork.Undo(); return(new CheckInOutput(null, false, "Error: Could Not Create Part Instance")); } } else { await this._unitOfWork.Undo(); return(new CheckInOutput(null, false, "Error: Part Not Found")); } }
public void UpdatePriceLog(PriceLog PriceLog) { Context.Entry(PriceLog).State = EntityState.Modified; Context.SaveChanges(); }
public void InsertPriceLog(PriceLog PriceLog) { Context.PriceLog.Add(PriceLog); Context.Entry(PriceLog).State = EntityState.Added; Context.SaveChanges();; }
public async Task <PriceEditOutput> ExecuteNew(PriceEditInput input) { var part = await this._partRepository.GetEntityAsync(e => e.Id == input.PartId); if (part == null) { return(new PriceEditOutput(null, false, "Error: Part Not Found")); } Price price = new Price(); price.LeadTime = input.LeadTime; price.MinOrder = input.MinOrder; price.TimeStamp = input.TimeStamp; price.UnitCost = input.UnitCost; price.ValidFrom = input.ValidFrom; price.ValidUntil = input.ValidUntil; price.DistributorId = input.DistributorId; if (input.PartInstanceId.HasValue) { var partInstance = await this._partInstanceRepository.GetEntityAsync(e => e.Id == input.PartInstanceId.Value); if (partInstance != null) { price.PartInstances.Add(partInstance); partInstance.UnitCost = price.UnitCost; if (partInstance.IsBubbler) { partInstance.TotalCost = (price.UnitCost * partInstance.BubblerParameter.NetWeight) * partInstance.Quantity; } else { partInstance.TotalCost = price.UnitCost * partInstance.Quantity; } PriceLog priceLog = new PriceLog(partInstance, price); await this._priceLogRepository.AddAsync(priceLog); await this._partInstanceRepository.UpdateAsync(partInstance); } else { return(new PriceEditOutput(null, false, "Error: PartInstance Not Found")); } } else { return(new PriceEditOutput(null, false, "Error: PartInstance Not Found")); } var priceAdded = await this._priceRepository.AddAsync(price); PartPrice partPrice = new PartPrice(part, price); var partPriceAdded = await this._partPriceRepository.AddAsync(partPrice); if (priceAdded != null && partPriceAdded != null) { var count = await this._unitOfWork.Save(); return(new PriceEditOutput(priceAdded, true, "Price Added and Saved")); } else { await this._unitOfWork.Undo(); return(new PriceEditOutput(null, false, "Error: New Price Save Failed")); } }