public ActionResult FillQuoteLines(FillQuoteLinesHelper model) { var quote = _db.Quotes.First(q => q.Id == model.quoteId); //Prepare variables for quote filling var archive = _quoteHelper.CheckArchiveAndAqcuireEmailOption(model.archiveOption); var acquireEmailOption = _quoteHelper.CheckArchiveAndAqcuireEmailOption(model.acquireEmail); var package = _quoteHelper.CheckPackage(model.package, model.documents, model.documentNumber); _db.QuoteLines.Add(new QuoteLine() { BaseAmount = 69, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = package.Price, Quantity = model.package.Contains(@"PREPAID") ? model.contractDuration : 1, LineTotal = model.package.Contains(@"PREPAID") ? package.Price * model.contractDuration : package.Price, RelatedQuoteId = model.quoteId, RelatedServiceId = package.ServiceId, Discount = 0 }); _db.SaveChanges(); if (package.InvoiceQuantity > 0 && !model.package.StartsWith("BUSINESS")) { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)2.49, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = 0, Quantity = package.InvoiceQuantity, LineTotal = model.package.Contains(@"PREPAID") ? (decimal)2.49 * package.InvoiceQuantity : 0, RelatedQuoteId = model.quoteId, RelatedServiceId = package.DocumentServiceId, Discount = 0 }); _db.SaveChanges(); } else { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)2.49, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = (decimal)2.19, Quantity = package.InvoiceQuantity, LineTotal = package.InvoiceQuantity * (decimal)2.19, RelatedQuoteId = model.quoteId, RelatedServiceId = package.DocumentServiceId, Discount = 0 }); _db.SaveChanges(); } if (archive) { if (model.package.Contains(@"PREPAID")) { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)0.5, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = package.ArchivePrice, Quantity = package.InvoiceQuantity, LineTotal = package.ArchivePrice * package.InvoiceQuantity, RelatedQuoteId = model.quoteId, RelatedServiceId = 32, Discount = 0 }); _db.SaveChanges(); } else { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)0.5, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = package.ArchivePrice, Quantity = package.InvoiceQuantity, LineTotal = package.InvoiceQuantity != 0 ? package.ArchivePrice * 1 : 0, RelatedQuoteId = model.quoteId, RelatedServiceId = 32, Discount = 0 }); _db.SaveChanges(); } } if (acquireEmailOption) { quote.AcquireEmailPayment = true; } else { quote.AcquireEmailPayment = false; } quote.ContractDuration = model.contractDuration; _db.SaveChanges(); _quoteHelper.UpdateQuoteSum(model.quoteId); return(Redirect(Request.UrlReferrer?.ToString())); }
public ActionResult FillQuoteLines(FillQuoteLinesHelper model) { var quote = _db.Quotes.First(q => q.Id == model.quoteId); //Prepare variables for quote filling var archive = _quoteHelper.CheckArchiveAndAqcuireEmailOption(model.archiveOption); var acquireEmailOption = _quoteHelper.CheckArchiveAndAqcuireEmailOption(model.acquireEmail); var package = _quoteHelper.CheckPackage(model.package, model.documents); _db.QuoteLines.Add(new QuoteLine() { BaseAmount = 69, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = package.Price, Quantity = 1, LineTotal = package.Price * 1, RelatedQuoteId = model.quoteId, RelatedServiceId = package.ServiceId }); _db.SaveChanges(); if (package.InvoiceQuantity > 0) { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)2.49, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = 0, Quantity = package.InvoiceQuantity, LineTotal = 0, RelatedQuoteId = model.quoteId, RelatedServiceId = package.DocumentServiceId }); _db.SaveChanges(); } if (archive) { _db.QuoteLines.Add(new QuoteLine() { BaseAmount = (decimal)0.5, InsertDate = DateTime.Now, LineNumber = _quoteHelper.CheckQuoteLineNumber(model.quoteId), Price = package.ArchivePrice, Quantity = package.InvoiceQuantity, LineTotal = package.ArchivePrice * 1, RelatedQuoteId = model.quoteId, RelatedServiceId = 1 //TO DO: ovdje dodati pravi ID }); _db.SaveChanges(); } if (acquireEmailOption) { quote.AcquireEmailPayment = true; } quote.ContractDuration = model.contractDuration; _db.SaveChanges(); _quoteHelper.UpdateQuoteSum(model.quoteId); return(Redirect(Request.UrlReferrer?.ToString())); }