public async Task <IActionResult> RetractAmount(CustomerVoucher customerVoucher) { var model = await _context.CustomerVouchers.Include(x => x.Customer) .Include(x => x.MerchantVoucher) .FirstOrDefaultAsync(m => m.Id == customerVoucher.Id); if (ModelState.IsValid) { var currentVoucher = _context.CustomerVouchers.FirstOrDefault(x => customerVoucher.Id == x.Id); if (customerVoucher != null && currentVoucher != null) { if (currentVoucher.Price < customerVoucher.Price || customerVoucher.Price < 0) { ModelState.AddModelError(String.Empty, "Bedrag kan niet hoger zijn dan huidige waarde."); return(View("Details", model)); } var newPrice = currentVoucher.Price - customerVoucher.Price; _voucherService.UpdatePrice(customerVoucher.Id, newPrice); return(RedirectToAction("Details", "CustomerVoucher", new { id = customerVoucher.Id })); } } return(View("Details", model)); }
public string EditCustomerVoucher(CustomerVoucher Model, FormCollection form) { string statusDDLValue = form["VoucherName"].ToString(); string msgClient; try { if (ModelState.IsValid) { var enditedCustomerVoucherValue = new LMS_Datas.CustomerVoucher { Active = true, CustomerId = Model.CustomerId, VoucherId = Model.VoucherId, AssignNo = Model.AssignNo }; entity.CustomerVouchers.Attach(enditedCustomerVoucherValue); entity.Entry(enditedCustomerVoucherValue).State = EntityState.Modified; entity.SaveChanges(); msgClient = "Saved Successfully"; } else { msgClient = "Validation data not successfully"; } } catch (Exception ex) { msgClient = "Error in Retriving Data"; } return(msgClient); }
public void AddMasterData(CustomerVoucher document) { if (String.IsNullOrEmpty(document.Id)) { document.Id = Guid.NewGuid().ToString(); } collectionCustomerVoucher.InsertOne(document); }
public string GetVoucherSoldHtml(CustomerVoucher voucher, string fileName) { var htmlVoucher = new StringBuilder(); var voucherImageUrl = _imageUrl + voucher.MerchantVoucher.Image; htmlVoucher.Append( $"<div style=\"align-content: center; justify-content: center; text-align: center; border-bottom: 1px solid grey;margin-bottom:1em\"><div> <img src=\"{voucherImageUrl}\" width=\"300\" style=\"display: block; margin: auto;\"> </div><div style=\"margin: 1em;\"> {voucher.MerchantVoucher.Name} t.w.v. € {voucher.MerchantVoucher.Price} </div><div> <img alt=\"Jouw voucher code:\" src=\"{fileName}\" width=\"150\" style=\"display: block; margin: auto;\"> </div> {voucher.Code} </div>"); return(htmlVoucher.ToString()); }
public void CreateCustomerVoucher(Customer customer, Voucher merchantVoucher, string responsePaymentId) { var customerVoucher = new CustomerVoucher { Customer = customer, MerchantVoucher = _context.MerchantVouchers.FirstOrDefault(x => x.Id == merchantVoucher.Id), PurchasedOn = DateTime.Now, Price = merchantVoucher.Price, Code = GenerateVoucherCode(12), EmailSent = false, Payment = _context.Payments.FirstOrDefault(x => x.Id == responsePaymentId) }; _context.CustomerVouchers.Add(customerVoucher); _context.SaveChanges(); }
public ActionResult Index(CustomerVoucher model, FormCollection form) { try { if (ModelState.IsValid) { string customerName = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.Name).First().ToString(); string mobileNumber = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.MobileNo).First().ToString(); mobileNumber = mobileNumber.Replace("(", String.Empty); mobileNumber = mobileNumber.Replace(")", String.Empty); mobileNumber = mobileNumber.Replace("-", String.Empty); mobileNumber = mobileNumber.Replace(" ", String.Empty); string vouchername = (from e in entity.Vouchers where e.VoucherId == model.VoucherId select e.VoucherName).First().ToString(); string mailId = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.EmailId).First().ToString(); using (var context = new LoyaltyManagementSystemEntities()) { var addCustomerVoucher = new LMS_Datas.CustomerVoucher() { CustomerId = model.CustomerId, VoucherId = model.VoucherId, AssignNo = model.AssignNo, AssignOn = DateTime.Now, Active = true }; context.CustomerVouchers.Add(addCustomerVoucher); //context.ClientDetails.Add(clientDetails); //etc add your other classes context.SaveChanges(); } ViewBag.CustomerId = new SelectList(entity.Customers.Where(models => models.Active == true), "CustomerId", "Name"); ViewBag.VoucherId = new SelectList(entity.Vouchers.Where(models => models.Activate == true), "VoucherId", "VoucherName"); ViewBag.alert = "Success"; builder.Append("Hello " + customerName + ",").AppendLine(); builder.Append("Voucher " + vouchername + " is assigned to you. Use Voucher No. " + model.AssignNo + " for further references.").AppendLine(); builder.Append("Thanks"); //sms.send(mobileNumber, builder); sms.send("8285601519", builder); Mail.send(builder, "*****@*****.**", "*****@*****.**", "Voucher Assigned"); } } catch (Exception e1) { ViewBag.alert = "Error"; } return(View()); }
public void UpdateMasterData(CustomerVoucher document) { throw new NotImplementedException(); }
private static void CreateBookingItems(BookingProcess bookingProcess, DateTime?bookingdate) { List <BookingProcessItem> list = new List <BookingProcessItem>(); BookingInquiry inquiry = new BookingInquiry(); inquiry.BookingProcessId = bookingProcess.Id; inquiry.CreateDate = bookingdate != null ? (DateTime)bookingdate : DateTime.Now; inquiry.DocumentId = bookingProcess.BookingNumber; inquiry.docType = "BookingInquiry"; manager.AddMasterData(inquiry); var bin = manager.GetBookingInquiryByBookingId(bookingProcess.Id); var bookinginquiry = new BookingProcessItem(); bookinginquiry.BookingProcessTyp = BookingProcessItemTyp.BookingInquiry; bookinginquiry.CreateDate = bookingdate != null ? (DateTime)bookingdate : DateTime.Now; bookinginquiry.DocumentId = bin.Id; bookinginquiry.LastChange = DateTime.Now; bookinginquiry.DocumentNr = bookingProcess.BookingNumber; bookinginquiry.DocumentTitel = "Sync"; bookinginquiry.DocumentStatus = DocumentStatus.Active; ProviderAnnouncement pan = new ProviderAnnouncement(); pan.BookingProcessId = bookingProcess.Id; pan.CreateDate = bookingdate != null ? (DateTime)bookingdate : DateTime.Now; pan.DocumentId = bookingProcess.BookingNumber; pan.docType = "ProviderAnnouncement"; manager.AddMasterData(pan); var p = manager.GetProviderAnnouncementByBookingId(bookingProcess.Id); var providerannouncement = new BookingProcessItem(); providerannouncement.BookingProcessTyp = BookingProcessItemTyp.ProviderAnnouncement; providerannouncement.CreateDate = bookingdate != null ? (DateTime)bookingdate : DateTime.Now; providerannouncement.DocumentId = p.Id; providerannouncement.LastChange = DateTime.Now; providerannouncement.DocumentNr = bookingProcess.BookingNumber; providerannouncement.DocumentTitel = "Sync"; providerannouncement.DocumentStatus = DocumentStatus.Active; ProviderConfirmation providerconfirmation = new ProviderConfirmation(); providerconfirmation.BookingProcessId = bookingProcess.Id; providerconfirmation.CreateDate = bookingdate != null ? ((DateTime)bookingdate).AddDays(1) : DateTime.Now; providerconfirmation.DocumentId = bookingProcess.BookingNumber; providerconfirmation.docType = "ProviderConfirmation"; manager.AddMasterData(providerconfirmation); var pconfirmation = manager.GetProviderConfirmationByBookingId(bookingProcess.Id); var pconf = new BookingProcessItem(); pconf.BookingProcessTyp = BookingProcessItemTyp.ProviderConfirmation; pconf.CreateDate = bookingdate != null ? ((DateTime)bookingdate).AddDays(1) : DateTime.Now; pconf.DocumentId = pconfirmation.Id; pconf.LastChange = DateTime.Now; pconf.DocumentNr = bookingProcess.BookingNumber; pconf.DocumentTitel = "Sync"; pconf.DocumentStatus = DocumentStatus.Active; BookingConfirmation bookingConfirmation = new BookingConfirmation(); bookingConfirmation.BookingProcessId = bookingProcess.Id; bookingConfirmation.CreateDate = bookingdate != null ? ((DateTime)bookingdate).AddDays(1) : DateTime.Now; bookingConfirmation.DocumentId = bookingProcess.BookingNumber; bookingConfirmation.docType = "BookingConfirmation"; manager.AddMasterData(bookingConfirmation); var bconfirmation = manager.GetBookingConfirmationByBookingId(bookingProcess.Id); var bconf = new BookingProcessItem(); bconf.BookingProcessTyp = BookingProcessItemTyp.BookingConfirmation; bconf.CreateDate = bookingdate != null ? ((DateTime)bookingdate).AddDays(1) : DateTime.Now; bconf.DocumentId = bconfirmation.Id; bconf.LastChange = DateTime.Now; bconf.DocumentNr = bookingProcess.BookingNumber; bconf.DocumentTitel = "Sync"; bconf.DocumentStatus = DocumentStatus.Active; CustomerVoucher customerVoucher = new CustomerVoucher(); customerVoucher.BookingProcessId = bookingProcess.Id; customerVoucher.CreateDate = bookingProcess.OfferInfo.CheckIn.AddDays(-20); customerVoucher.DocumentId = bookingProcess.BookingNumber; customerVoucher.docType = "CustomerVoucher"; manager.AddMasterData(customerVoucher); var cvoucher = manager.GetCustomerVoucherByBookingId(bookingProcess.Id); var cvouchera = new BookingProcessItem(); cvouchera.BookingProcessTyp = BookingProcessItemTyp.CustomerVoucher; cvouchera.CreateDate = bookingProcess.OfferInfo.CheckIn.AddDays(-20); cvouchera.DocumentId = cvoucher.Id; cvouchera.LastChange = DateTime.Now; cvouchera.DocumentNr = bookingProcess.BookingNumber; cvouchera.DocumentTitel = "Sync"; cvouchera.DocumentStatus = DocumentStatus.Active; BookingInvoice bookingInvoice = new BookingInvoice(); bookingInvoice.BookingProcessId = bookingProcess.Id; bookingInvoice.CreateDate = bookingProcess.OfferInfo.CheckIn.AddDays(-20); bookingInvoice.DocumentId = bookingProcess.BookingNumber; bookingInvoice.docType = "BookingInvoice"; manager.AddMasterData(bookingInvoice); var bookinvoice = manager.GetBookingInvoiceByBookingId(bookingProcess.Id); var binvoice = new BookingProcessItem(); binvoice.BookingProcessTyp = BookingProcessItemTyp.BookingInvoice; binvoice.CreateDate = bookingProcess.OfferInfo.CheckIn.AddDays(-20); binvoice.DocumentId = bookinvoice.Id; binvoice.LastChange = DateTime.Now; binvoice.DocumentNr = bookingProcess.BookingNumber; binvoice.DocumentTitel = "Sync"; binvoice.DocumentStatus = DocumentStatus.Active; list.AddRange(new BookingProcessItem[] { bookinginquiry, providerannouncement, pconf, bconf, cvouchera, binvoice }); bookingProcess.BookingProcessItemList = list; }