public IEnumerable <IPPurchaseModel> FilterIPPurchase() { //var allIPQuotesDB = AMDSystemsEntities.ip_quotes.Where(e => !(e.is_quote_delete.HasValue && e.is_quote_delete.Value)).Where(e=> e.type==2).Select(c => c).OrderByDescending(e => e.quote_id).ToList(); //var allIPQuotesModel = new List<IPPurchaseModel>(); //allIPQuotesDB.ForEach(c => allIPQuotesModel.Add(Mapper.Convert(c,true))); var allIPQuotesDB = AMDSystemsEntities.ip_quotes.Join(AMDSystemsEntities.ip_clients, a => a.client_id, b => b.client_id, (a, b) => new { a, b }) .Join(AMDSystemsEntities.ip_quote_amounts, c => c.a.quote_id, d => d.quote_id, (c, d) => new { c, d }) .Where(e => !(e.c.a.is_quote_delete.HasValue && e.c.a.is_quote_delete.Value)) .Where(c => c.c.a.type == 0).Select(c => c) .OrderByDescending(e => e.c.a.quote_id).ToList(); var allIPQuotesModel = new List <IPPurchaseModel>(); foreach (var item in allIPQuotesDB) { IPPurchaseModel ip_q_temp = new IPPurchaseModel(); ip_q_temp.client_id = item.c.a.client_id; ip_q_temp.delivery_notes = item.c.a.delivery_notes; ip_q_temp.invoice_group_id = item.c.a.invoice_group_id; ip_q_temp.notes = item.c.a.notes; ip_q_temp.quote_id = item.c.a.quote_id; ip_q_temp.user_id = item.c.a.user_id; ip_q_temp.quote_status_id = item.c.a.quote_status_id; ip_q_temp.quote_date_created = item.c.a.quote_date_created; ip_q_temp.quote_date_modified = item.c.a.quote_date_modified; ip_q_temp.client_id = item.c.a.client_id; ip_q_temp.quote_discount_amount = item.c.a.quote_discount_amount; ip_q_temp.client_name = item.c.b.client_name; //ip_q_temp.quote_total = item.d.quote_total; allIPQuotesModel.Add(ip_q_temp); } return(allIPQuotesModel); }
public ActionResult CreatePurchase(IPPurchaseModel model) { model.type = 2; var id = quoteService.Add(model); return(RedirectToAction("Purchase", "Purchase", new { id = id })); }
public static ip_quotes Map(IPPurchaseModel iPQuotesModel, ip_quotes ipQuotesDB) { if (iPQuotesModel == null) { //throw new ArgumentNullException(nameof(iPQuotesModel)); } if (ipQuotesDB == null) { //throw new ArgumentNullException(nameof(ipQuotesDB)); } ipQuotesDB.client_id = iPQuotesModel.client_id; ipQuotesDB.invoice_group_id = iPQuotesModel.invoice_group_id; ipQuotesDB.type = iPQuotesModel.type; ipQuotesDB.notes = iPQuotesModel.notes; ipQuotesDB.quote_date_created = iPQuotesModel.quote_date_created; ipQuotesDB.quote_date_expires = iPQuotesModel.quote_date_expires; ipQuotesDB.quote_date_modified = iPQuotesModel.quote_date_modified; ipQuotesDB.quote_discount_amount = iPQuotesModel.quote_discount_amount; ipQuotesDB.quote_discount_percent = iPQuotesModel.quote_discount_percent; ipQuotesDB.quote_number = iPQuotesModel.quote_number; ipQuotesDB.quote_password = iPQuotesModel.quote_password; ipQuotesDB.quote_status_id = iPQuotesModel.quote_status_id; ipQuotesDB.quote_url_key = iPQuotesModel.quote_url_key; ipQuotesDB.taxType = iPQuotesModel.taxType; ipQuotesDB.user_id = iPQuotesModel.user_id; return(ipQuotesDB); }
public IPQuoteAmountsModel FilterIPPurchaseAmounts(IPPurchaseModel model) { var allIPQuoteAmountsDB = AMDSystemsEntities.ip_quote_amounts.Where(qa => qa.quote_id == model.quote_id).FirstOrDefault(); if (allIPQuoteAmountsDB == null) { return(new IPQuoteAmountsModel()); } return(Mapper.Convert(allIPQuoteAmountsDB)); }
public void UpdatePurchase(IPPurchaseModel iPQuotesModel) { var ipQuotesDB = AMDSystemsEntities.ip_quotes.Where(c => c.quote_id == iPQuotesModel.quote_id).FirstOrDefault(); ipQuotesDB.quote_status_id = iPQuotesModel.quote_status_id; ipQuotesDB.quote_date_modified = DateTime.Now; ipQuotesDB.is_quote = iPQuotesModel.quote_status_id == 4 ? false : true; ipQuotesDB.taxType = iPQuotesModel.taxType; AMDSystemsEntities.SaveChanges(); }
// GET: IPInvoices public ActionResult CreatePurchase(int?Client_ID) { IPPurchaseModel quoteModel = new IPPurchaseModel(); if (Client_ID.HasValue) { quoteModel.client_id = Client_ID.Value; } return(View(quoteModel)); }
public IPQuoteTaxRatesModel FilterIPQuoteTaxRates(IPPurchaseModel model) { var ipQuoteTaxRatesDB = AMDSystemsEntities.ip_quote_tax_rates.Where(qtr => qtr.quote_id == model.quote_id).FirstOrDefault(); if (ipQuoteTaxRatesDB == null) { return(new IPQuoteTaxRatesModel()); } var ipQuoteTaxRatesModel = Mapper.Convert(ipQuoteTaxRatesDB); return(ipQuoteTaxRatesModel); }
public IEnumerable <IPQuoteItemsModel> FilterIPQuoteItems(IPPurchaseModel model) { var ipQuoteItemsDB = AMDSystemsEntities.ip_quote_items.Where(qt => qt.quote_id == model.quote_id).ToList(); if (ipQuoteItemsDB.Count() == 0) { return(new List <IPQuoteItemsModel>()); } var ipQuoteItemsModel = ipQuoteItemsDB.Select(e => Mapper.Convert(e)); return(ipQuoteItemsModel); }
public int Add(IPPurchaseModel iPQuotesModel) { if (iPQuotesModel == null) { //throw new ArgumentNullException(nameof(iPQuotesModel)); } iPQuotesModel.quote_date_created = DateTime.Now; iPQuotesModel.quote_date_modified = DateTime.Now; iPQuotesModel.quote_date_expires = DateTime.Now.AddMonths(12); iPQuotesModel.quote_url_key = string.IsNullOrEmpty(iPQuotesModel.quote_url_key) ? string.Empty : iPQuotesModel.quote_url_key; iPQuotesModel.invoice_group_id = iPQuotesModel.invoice_group_id == 0 ? 1 : iPQuotesModel.invoice_group_id; iPQuotesModel.user_id = iPQuotesModel.user_id == 0 ? 1 : iPQuotesModel.user_id; ip_quotes ipQuotesDB = Mapper.Map(iPQuotesModel, new ip_quotes()); AMDSystemsEntities.ip_quotes.Add(ipQuotesDB); AMDSystemsEntities.SaveChanges(); return(ipQuotesDB.quote_id); }
public ActionResult UpdatePurchase(IPPurchaseModel model) { // model.quote_tax_rate.quote_id = model.quote_id; //model.quote_amount.quote_id = model.quote_id; quoteService.Update(model); if (model.quote_items != null) { quoteItemService.Update(model.quote_items, model.quote_id); } model.quote_amount.quote_id = model.quote_id; quoteAmountsService.Update(model.quote_amount); if (model.payment != null) { model.payment.quote_id = model.quote_id; paymentService.Update(model.payment); } //quoteTaxRatesService.Update(model.quote_tax_rate); return(RedirectToAction("Purchase", new { id = model.quote_id })); }
public void Add(IPPurchaseModel iPPurchaseModel) { throw new NotImplementedException(); }