public ActionResult AddReciept(RecieptViewModel collection) { string userId = User.Identity.GetUserId(); DB_Entities db = new DB_Entities(); var count = db.Reciepts.Where(x => x.UserId == userId && x.Title == collection.Title && x.InstituteId == collection.InstituteId).Count(); if (!(count > 0)) { string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName); string ext = Path.GetExtension(collection.Image.FileName); filename = filename + DateTime.Now.Millisecond.ToString(); filename = filename + ext; string filetodb = "/Reciepts/" + filename; filename = Path.Combine(Server.MapPath("~/Files/Reciepts/"), filename); collection.Image.SaveAs(filename); collection.Photo = filetodb; Reciept res = new Reciept() { Title = collection.Title, InstituteId = collection.InstituteId, Date = collection.Date, DateAdded = DateTime.Now, Image = collection.Photo, Amount = collection.Amount, UserId = userId }; db.Reciepts.Add(res); db.SaveChanges(); Alerts.RecieptAdded = true; return(RedirectToAction("ViewReciepts", "DashBoard")); } Alerts.Exist = true; return(RedirectToAction("AddReciept", "DashBoard")); }
public ActionResult ViewReciepts(DateViewModel date) { List <double> amountlist = new List <double>(); string userId = User.Identity.GetUserId(); var reciepts = (new DB_Entities()).Reciepts.Where(x => x.UserId == userId).Where(y => y.Date > date.startDate && y.Date < date.endDate).ToList <Reciept>(); List <RecieptViewModel> Reciepts = new List <RecieptViewModel>(); foreach (var i in reciepts as List <Reciept> ) { RecieptViewModel res = new RecieptViewModel() { Id = i.Id, Title = i.Title, InstituteName = GetInstituteName(i.InstituteId), Amount = Convert.ToDouble(i.Amount), Date = Convert.ToDateTime(i.Date), Photo = i.Image }; amountlist.Add(Convert.ToDouble(i.Amount)); Reciepts.Add(res); } ViewData["totalamount"] = amountlist.Sum(); ViewData["reciepts"] = Reciepts; return(View()); }
public RecieptView() { InitializeComponent(); var viewmodel = new RecieptViewModel(); BindingContext = viewmodel; }
public ActionResult ViewReciept(int?id) { DB_Entities db = new DB_Entities(); var bill = db.Reciepts.Where(x => x.Id == id).FirstOrDefault(); RecieptViewModel reciept = new RecieptViewModel() { Title = bill.Title, InstituteName = GetInstituteName(bill.InstituteId), Amount = Convert.ToDouble(bill.Amount), Date = Convert.ToDateTime(bill.Date), Photo = bill.Image }; ViewData["reciept"] = reciept; return(View()); }
// GET: Pdf public ActionResult Receipt(int orderId, string payment, float total) { WebShopMobileDb Db = new WebShopMobileDb(); var user = User.Identity.Name; var model = Methods.FindCartOrder(user); var customer = Db.Customers.FirstOrDefault(x => x.EmailAdress == user); var model2 = Db.Orders.FirstOrDefault(x => x.Id == model.Id); model2.Processed = true; Db.SaveChanges(); model.OrderDate = DateTime.Now.ToShortDateString(); var reciept = new RecieptViewModel(model, customer, payment, total); return(Pdf(reciept)); }
public async Task <IActionResult> CheckOutConfirmed(int id) { DateTime now = DateTime.Now; var parkedVehicle = await _context.ParkedVehicle.FindAsync(id); var model = new RecieptViewModel { RegNum = parkedVehicle.RegNum, Color = parkedVehicle.Color, CheckInTime = parkedVehicle.CheckInTime, CheckOutTime = now, TotalTime = now - parkedVehicle.CheckInTime, VehicleType = _context.VehicleType.Any(v => v.Id == parkedVehicle.VehicleTypeId) ? _context.VehicleType.First(v => v.Id == parkedVehicle.VehicleTypeId).Name : "" }; _context.ParkedVehicle.Remove(parkedVehicle); await _context.SaveChangesAsync(); //var Parkedhours = model.CheckOutTime - model.CheckInTime; //model.TotalTime = string.Format("{0:D2}:{1:D2}:{2:D2}", Parkedhours.Days, Parkedhours.Hours, Parkedhours.Minutes); //model.Price = String.Format("{0:F2}", Parkedhours.TotalHours * 10); ; // TempData["Message"] = $"Vehicle \'{parkedVehicle.RegNum}\' is checked out"; //var model = new RecieptViewModel //{ // RegNum = parkedVehicle.RegNum, // Color = parkedVehicle.Color, // CheckInTime = parkedVehicle.CheckInTime, // CheckOutTime = DateTime.Now, // TotalTime = DateTime.Now - parkedVehicle.CheckInTime, // VehicleType = _context.VehicleType.Any(v => v.Id == parkedVehicle.VehicleTypeId) ? // _context.VehicleType.First(v => v.Id == parkedVehicle.VehicleTypeId).Name : "" //}; return(View("Reciept", model)); }