public ActionResult RecurringReceipt(RecurringReceipt model) { if (!User.Identity.IsAuthenticated) return RedirectToAction("LogOn", "Account"); var scope = ObjectScopeProvider1.GetNewObjectScope(); if (Checkauthorization(scope, User.Identity.Name)) { if (model.SignatureImage != null) { var donationReceiver = (from c in scope.GetOqlQuery<User>().ExecuteEnumerable() where c.IsheDonationReceiver.Equals(true) && c.Username.Equals(Request.Form["CmbDonationReceivedBy"]) select c).ToList(); if (donationReceiver.Count > 0) { scope.Transaction.Begin(); var receipt = new Receipt { Address = model.Address, Address2 = model.Address2, Contact = model.Contact, ReceiptNumber = model.ReceiptNumber, DonationReceiver = donationReceiver[0], DonationAmountinWords = model.DonationAmountinWords, Email = model.Email, DateReceived = DateTime.Now, FirstName = model.FirstName, City = model.City, LastName = model.LastName, Mi = model.Mi, State = model.State, ZipCode = model.ZipCode, IssuedDate = model.IssuedDate, ReceiptType = ReceiptType.RecurringReceipt }; for (int i = 0; i < model.RecurrenceDates.Count(); i++) { try { var recurringDetails = new RecurringDetails { DueDate = Convert.ToDateTime(model.RecurrenceDates[i]), Amount = model.RecurrenceAmount[i] }; switch (model.RecurrenceModeofPayment[i]) { case "Cash": { recurringDetails.ModeOfPayment = ModeOfPayment.Cash; break; } case "Cheque": { recurringDetails.ModeOfPayment = ModeOfPayment.Cheque; break; } case "Mobile": { recurringDetails.ModeOfPayment = ModeOfPayment.Mobile; break; } case "Goods": { recurringDetails.ModeOfPayment = ModeOfPayment.Goods; break; } case "Online": { recurringDetails.ModeOfPayment = ModeOfPayment.Online; break; } } receipt.RecurringDetails.Add(recurringDetails); } catch (Exception) { continue; } } // saving image here try { var signature = new SignatureImage { Filename = model.SignatureImage.FileName }; Stream fileStream = model.SignatureImage.InputStream; int fileLength = model.SignatureImage.ContentLength; signature.Filedata = new byte[fileLength]; fileStream.Read(signature.Filedata, 0, fileLength); signature.MimeType = model.SignatureImage.ContentType; signature.ID = Guid.NewGuid(); receipt.SignatureImage = signature; } catch { } scope.Add(receipt); scope.Transaction.Commit(); ViewData["ReceiptID"] = receipt.ReceiptNumber; return View("Printoptions"); } } LoadReceiptValuesFromDb(scope); ViewData["PostAction"] = "RecurringReceipt"; ViewData["selectedModeOfPayment"] = Request.Form["cmbModeOfPayment"]; ViewData["selectedDonationReceivedBy"] = Request.Form["CmbDonationReceivedBy"]; ModelState.AddModelError("", "Unable to generate receipt due to invalid parameter passed."); return View(); } ViewData["Status"] = "You are not authorized to do this operation"; return View("PartialViewStatus"); }
public ActionResult EditReceipt(string recpId) { if (!User.Identity.IsAuthenticated) return RedirectToAction("LogOnPage", "Account"); var scope = ObjectScopeProvider1.GetNewObjectScope(); if (CheckAdminauthorization(scope, User.Identity.Name)) { List<Receipt> receipts = (from c in scope.GetOqlQuery<Receipt>().ExecuteEnumerable() where c.ReceiptNumber.ToLower().Equals(recpId.ToLower()) select c).ToList(); if (receipts.Count > 0) { LoadReceiptValuesFromDb(scope); var receipt = receipts[0]; switch (receipt.ReceiptType) { case ReceiptType.GeneralReceipt: { var model = new RegularReceiptModels { Address = receipt.Address, Address2 = receipt.Address2, Contact = receipt.Contact, DateReceived = receipt.DateReceived, DonationAmount = Convert.ToDouble(receipt.DonationAmount), DonationAmountinWords = receipt.DonationAmountinWords, Email = receipt.Email, City = receipt.City, FirstName = receipt.FirstName, LastName = receipt.LastName, Mi = receipt.Mi, ReceiptNumber = receipt.ReceiptNumber, State = receipt.State, ZipCode = receipt.ZipCode, IssuedDate = receipt.IssuedDate }; ViewData["PostAction"] = "UpdateRegularReceipt"; ViewData["selectedModeOfPayment"] = receipt.ModeOfPayment.ToString(); ViewData["selectedDonationReceivedBy"] = receipt.DonationReceiver.Username; return View("EditRegularReceipt", model); } case ReceiptType.RecurringReceipt: { var model = new RecurringReceipt { Address = receipt.Address, Address2 = receipt.Address2, Contact = receipt.Contact, Email = receipt.Email, ReceiptNumber = receipt.ReceiptNumber, City = receipt.City, FirstName = receipt.FirstName, LastName = receipt.LastName, DonationAmountinWords = receipt.DonationAmountinWords, Mi = receipt.Mi, State = receipt.State, ZipCode = receipt.ZipCode, IssuedDate = receipt.IssuedDate, RecurrenceAmount = receipt.RecurringDetails.Select(m => m.Amount).ToList().ToArray(), RecurrenceDates = receipt.RecurringDetails.Select(m => m.DueDate).ToList().ToArray(), RecurrenceModeofPayment = receipt.RecurringDetails.Select(m => m.ModeOfPayment.ToString()).ToList().ToArray() }; List<RecurrenceData> recurrenceData = receipt.RecurringDetails.Select(rd => new RecurrenceData { Amount = rd.Amount, Date = rd.DueDate.ToString("MM/dd/yyy"), ModeOfPayment = rd.ModeOfPayment.ToString() }).ToList(); ViewData["RecurringDetails"] = recurrenceData; ViewData["PostAction"] = "UpdateRecurringReceipt"; ViewData["selectedModeOfPayment"] = receipt.ModeOfPayment.ToString(); ViewData["selectedDonationReceivedBy"] = receipt.DonationReceiver.Username; return View("EditRecurringReceipt", model); } case ReceiptType.MerchandiseReceipt: { var model = new MerchandiseReceipt { Address = receipt.Address, Address2 = receipt.Address2, Contact = receipt.Contact, DateReceived = receipt.DateReceived, Email = receipt.Email, ReceiptNumber = receipt.ReceiptNumber, MerchandiseItem = receipt.MerchandiseItem, Value = Convert.ToDouble(receipt.FmvValue), City = receipt.City, FirstName = receipt.FirstName, LastName = receipt.LastName, Mi = receipt.Mi, Quanity = receipt.Quantity, State = receipt.State, ZipCode = receipt.ZipCode, IssuedDate = receipt.IssuedDate }; ViewData["selectedDonationReceivedBy"] = receipt.DonationReceiver.Username; ViewData["PostAction"] = "UpdateMerchandiseReceipt"; return View("EditMerchandiseReceipt", model); } case ReceiptType.ServicesReceipt: { var model = new ServicesReceipt { Address = receipt.Address, Address2 = receipt.Address2, Contact = receipt.Contact, DateReceived = receipt.DateReceived, Email = receipt.Email, ReceiptNumber = receipt.ReceiptNumber, HoursServed = receipt.HoursServed, City = receipt.City, FirstName = receipt.FirstName, FmvValue = Convert.ToDouble(receipt.FmvValue), LastName = receipt.LastName, Mi = receipt.Mi, RateperHour = Convert.ToDouble(receipt.RatePerHrOrDay), IssuedDate = receipt.IssuedDate, ServiceType = receipt.ServiceType, State = receipt.State, ZipCode = receipt.ZipCode }; ViewData["selectedDonationReceivedBy"] = receipt.DonationReceiver.Username; ViewData["PostAction"] = "UpdateServicesReceipt"; return View("EditServicesReceipt", model); } } } ViewData["Status"] = "The receipt not found for the given id."; return View("Status"); } ViewData["Status"] = "You are not authorized to do this operation"; return View("PartialViewStatus"); }
public ActionResult RecurringReceipt() { if (!User.Identity.IsAuthenticated) return RedirectToAction("LogOn", "Account"); var scope = ObjectScopeProvider1.GetNewObjectScope(); if (Checkauthorization(scope, User.Identity.Name)) { LoadReceiptValuesFromDb(scope); ViewData["PostAction"] = "RecurringReceipt"; ViewData["selectedModeOfPayment"] = string.Empty; ViewData["selectedDonationReceivedBy"] = string.Empty; var receiptModel = new RecurringReceipt { ReceiptNumber = Utilities.GenerateReceiptId(), IssuedDate = DateTime.Now }; return View(receiptModel); } ViewData["Status"] = "You are not authorized to do this operation"; return View("PartialViewStatus"); }
public ActionResult UpdateRecurringReceipt(RecurringReceipt model) { if (!User.Identity.IsAuthenticated) return RedirectToAction("LogOn", "Account"); var scope = ObjectScopeProvider1.GetNewObjectScope(); if (CheckAdminauthorization(scope, User.Identity.Name)) { var donationReceiver = (from c in scope.GetOqlQuery<User>().ExecuteEnumerable() where c.IsheDonationReceiver.Equals(true) && c.Username.Equals(Request.Form["CmbDonationReceivedBy"]) select c).ToList(); if (donationReceiver.Count > 0) { List<Receipt> receipts = (from c in scope.GetOqlQuery<Receipt>().ExecuteEnumerable() where c.ReceiptNumber.ToLower().Equals(model.ReceiptNumber.ToLower()) select c).ToList(); if (receipts.Count > 0) { scope.Transaction.Begin(); var receipt = receipts[0]; receipt.Address = model.Address; receipt.Address2 = model.Address2; receipt.Contact = model.Contact; receipt.ReceiptNumber = model.ReceiptNumber; receipt.DonationReceiver = donationReceiver[0]; receipt.Email = model.Email; receipt.FirstName = model.FirstName; receipt.Mi = model.Mi; receipt.LastName = model.LastName; receipt.City = model.City; receipt.State = model.State; receipt.ZipCode = model.ZipCode; receipt.ReceiptType = ReceiptType.RecurringReceipt; receipt.IssuedDate = model.IssuedDate; receipt.DonationAmountinWords = model.DonationAmountinWords; receipt.RecurringDetails.Clear(); for (int i = 0; i < model.RecurrenceDates.Count(); i++) { try { var recurringDetails = new RecurringDetails { DueDate = Convert.ToDateTime(model.RecurrenceDates[i]), Amount = model.RecurrenceAmount[i] }; switch (model.RecurrenceModeofPayment[i]) { case "Cash": { recurringDetails.ModeOfPayment = ModeOfPayment.Cash; break; } case "Cheque": { recurringDetails.ModeOfPayment = ModeOfPayment.Cheque; break; } case "Mobile": { recurringDetails.ModeOfPayment = ModeOfPayment.Mobile; break; } case "Goods": { recurringDetails.ModeOfPayment = ModeOfPayment.Goods; break; } case "Online": { recurringDetails.ModeOfPayment = ModeOfPayment.Online; break; } } receipt.RecurringDetails.Add(recurringDetails); } catch (Exception) { continue; } } if (model.SignatureImage != null) { // saving image here try { var signature = new SignatureImage { Filename = model.SignatureImage.FileName }; Stream fileStream = model.SignatureImage.InputStream; int fileLength = model.SignatureImage.ContentLength; signature.Filedata = new byte[fileLength]; fileStream.Read(signature.Filedata, 0, fileLength); signature.MimeType = model.SignatureImage.ContentType; signature.ID = Guid.NewGuid(); receipt.SignatureImage = signature; } catch { } } scope.Add(receipt); scope.Transaction.Commit(); ViewData["Status"] = "Updated successfully."; return View("Status"); } } ViewData["Status"] = "Unable to generate receipt due to invalid parameter passed."; return View("Status"); } ViewData["Status"] = "You are not authorized to do this operation"; return View("Status"); }