public PriceSheetViewModel GetPriceSheet(Guid priceSheetId) { var priceSheet = _priceSheetRepository.GetPriceSheet(priceSheetId); PriceSheetViewModel model = new PriceSheetConverter().ConvertToView(priceSheet); return(model); }
public ActionResult Production(Guid priceSheetId) { var priceSheet = _priceSheetRepository.GetPriceSheet(priceSheetId); PriceSheetViewModel model = new PriceSheetConverter().ConvertToView(priceSheet); return(View(model)); }
public JsonResult GetPriceSheetsByProject(Guid projectId, DateTime?fromDate, DateTime?toDate, string orderType) { var model = new PriceSheetViewModel(); var priceSheets = new List <PriceSheetViewModel>(); if (orderType.Equals("Sample") || orderType.Equals("Tooling")) { var dbPriceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.ProjectId == projectId && x.IsQuote == true).ToList(); if (dbPriceSheets != null && dbPriceSheets.Count > 0) { foreach (var priceSheet in dbPriceSheets) { var priceSheetModel = new PriceSheetConverter().ConvertToView(priceSheet); priceSheets.Add(priceSheetModel); } } } else { var dbPriceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.ProjectId == projectId && x.IsProduction == true).ToList(); if (dbPriceSheets != null && dbPriceSheets.Count > 0) { foreach (var priceSheet in dbPriceSheets) { var priceSheetModel = new PriceSheetConverter().ConvertToView(priceSheet); priceSheets.Add(priceSheetModel); } } } if (fromDate != null) { priceSheets = priceSheets.Where(x => x.DueDate >= fromDate).ToList(); } if (toDate != null) { priceSheets = priceSheets.Where(x => x.DueDate <= toDate).ToList(); } model.PriceSheets = priceSheets; return(Json(model.PriceSheets, JsonRequestBehavior.AllowGet)); }
public JsonResult Edit(PriceSheetViewModel priceSheet) { var operationResult = new OperationResult(); PriceSheet priceSheetToUpdate = new PriceSheet(); var priceSheetId = priceSheet.PriceSheetId; priceSheetToUpdate = new PriceSheetConverter().ConvertToDomain(priceSheet); operationResult = _priceSheetRepository.UpdatePriceSheet(priceSheetToUpdate); if (operationResult.Success) { if (priceSheet.CostDetailList != null && priceSheet.CostDetailList.Count > 0) { foreach (var costDetail in priceSheet.CostDetailList) { var priceDetail = priceSheet.PriceDetailList.FirstOrDefault(x => x.ProjectPartId == costDetail.ProjectPartId); var tempPart = _projectPartRepository.GetProjectPart(costDetail.ProjectPartId); { tempPart.Weight = costDetail.Weight; tempPart.AnnualUsage = (int)costDetail.AnnualUsage; tempPart.Cost = costDetail.Cost; tempPart.PatternCost = costDetail.PatternCost; tempPart.FixtureCost = costDetail.FixtureCost; tempPart.PriceSheetId = priceSheetId; tempPart.Price = priceDetail.Price; tempPart.PatternPrice = priceDetail.PatternPrice; tempPart.FixturePrice = priceDetail.FixturePrice; } operationResult = _projectPartRepository.UpdateProjectPart(tempPart); } } if (priceSheetToUpdate.IsProduction) { operationResult = EditPriceSheetParts(priceSheetToUpdate.PriceSheetId); } operationResult.ReferenceId = priceSheetId; } return(Json(operationResult, JsonRequestBehavior.AllowGet)); }
public ActionResult ConvertToProduction(Guid priceSheetId, Guid quoteId) { var model = new PriceSheetViewModel(); var existingPriceSheet = _priceSheetRepository.GetPriceSheet(priceSheetId); if (existingPriceSheet != null) { model = new PriceSheetConverter().ConvertToView(existingPriceSheet); var newPriceSheetNumber = PriceSheetNumber(); model.Number = newPriceSheetNumber; _priceSheetRepository.RemovePriceSheetNumber(newPriceSheetNumber); model.QuoteId = quoteId; var quoteParts = _projectPartRepository.GetProjectParts().Where(x => x.QuoteId == quoteId).ToList(); if (model.CostDetailList != null && quoteParts != null) { var deletePartList = new List <PriceSheetCostDetailViewModel>(); foreach (var costPart in model.CostDetailList) { var existing = quoteParts.FirstOrDefault(x => x.ProjectPartId == costPart.ProjectPartId); if (existing == null) { deletePartList.Add(costPart); } } if (deletePartList != null && deletePartList.Count > 0) { foreach (var deletePart in deletePartList) { model.CostDetailList.Remove(deletePart); } } } } return(View(model)); }
public ActionResult Index() { PriceSheetListModel model = new PriceSheetListModel(); model.PriceSheets = new List <PriceSheetListModel>(); var priceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.IsProduction).ToList(); if (priceSheets != null && priceSheets.Count > 0) { foreach (var priceSheet in priceSheets) { PriceSheetListModel sheetModel = new PriceSheetConverter().ConvertToListView(priceSheet); model.PriceSheets.Add(sheetModel); } } return(View(model)); }
public JsonResult GetQuotePriceSheets() { var model = new PriceSheetListModel(); var priceSheets = new List <PriceSheetListModel>(); var tempPriceSheets = _priceSheetRepository.GetPriceSheets().Where(x => x.IsQuote).ToList(); if (tempPriceSheets != null && tempPriceSheets.Count > 0) { foreach (var tempPriceSheet in tempPriceSheets) { var priceSheetModel = new PriceSheetConverter().ConvertToListView(tempPriceSheet); priceSheets.Add(priceSheetModel); } } model.PriceSheets = priceSheets.OrderBy(x => x.Number).ToList(); return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult Create(PriceSheetViewModel priceSheet) { var operationResult = new OperationResult(); var rfq = _rfqRepository.GetRfq(priceSheet.RfqId); var newPriceSheet = new PriceSheetConverter().ConvertToDomain(priceSheet); operationResult = _priceSheetRepository.SavePriceSheet(newPriceSheet); if (operationResult.Success && priceSheet.IsQuote) { rfq.IsOpen = false; operationResult = _rfqRepository.UpdateRfq(rfq); } var insertedPriceSheet = _priceSheetRepository.GetPriceSheet(priceSheet.Number); if (operationResult.Success) { if (priceSheet.CostDetailList != null && priceSheet.CostDetailList.Count > 0) { foreach (var costDetail in priceSheet.CostDetailList) { var priceDetail = priceSheet.PriceDetailList.FirstOrDefault(x => x.ProjectPartId == costDetail.ProjectPartId); var tempPart = _projectPartRepository.GetProjectPart(costDetail.ProjectPartId); { tempPart.Weight = costDetail.Weight; tempPart.AnnualUsage = (int)costDetail.AnnualUsage; tempPart.Cost = costDetail.Cost; tempPart.PatternCost = costDetail.PatternCost; tempPart.FixtureCost = costDetail.FixtureCost; tempPart.PriceSheetId = insertedPriceSheet.PriceSheetId; tempPart.Price = priceDetail.Price; tempPart.PatternPrice = priceDetail.PatternPrice; tempPart.FixturePrice = priceDetail.FixturePrice; } operationResult = _projectPartRepository.UpdateProjectPart(tempPart); } } if (operationResult.Success && priceSheet.IsQuote) { operationResult = _rfqRepository.UpdatePriceSheet(rfq.RfqId, priceSheet.Number); } else if (priceSheet.IsProduction && operationResult.Success) { if (priceSheet.QuoteId != Guid.Empty) { var quote = _quoteRepository.GetQuote(priceSheet.QuoteId); quote.IsOpen = false; operationResult = _quoteRepository.UpdateQuote(quote); } ConvertProjectPartsToParts(insertedPriceSheet.PriceSheetId); } } operationResult.ReferenceId = insertedPriceSheet.PriceSheetId; return(Json(operationResult, JsonRequestBehavior.AllowGet));; }