public async Task <IActionResult> PutServiceBooking(int id, ServiceBooking serviceBooking) { if (id != serviceBooking.Id) { return(BadRequest()); } _context.Entry(serviceBooking).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServiceBookingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ServiceBookingItem(ServiceBooking serviceBooking, Service service, long price) { _serviceBooking = serviceBooking; _service = service; _price = price; _currentPrice = service.GetPriceForVehicle(serviceBooking.VehicleRegistration.RegisteredVehicle); }
public ActionResult DeleteConfirmed(int id) { ServiceBooking serviceBooking = db.ServiceBooking.Find(id); db.ServiceBooking.Remove(serviceBooking); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Booking_Id,BookingDate,BookingStatus")] ServiceBooking serviceBooking) { if (ModelState.IsValid) { db.Entry(serviceBooking).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serviceBooking)); }
public CarsController() { myService = new ServiceCar(); serviceRating = new ServiceRating(); serviceSubCategory = new ServiceSubCategory(); serviceCarModel = new ServiceCarModel(); serviceCreation = new ServiceCreationYear(); serviceType = new ServiceTypeCar(); serviceBooking = new ServiceBooking(); serviceImage = new ServiceImage(); serviceUser = new ServiceUser(); }
public ActionResult Create([Bind(Include = "Booking_Id,BookingDate,BookingStatus,Service,ServiceTimings")] ServiceBooking serviceBooking) { // int s_Id = serviceBooking.Service.Service_Id; // int t_Id = serviceBooking.ServiceTimings.Timing_Id; serviceBooking.BookingStatus = true; Service service = db.Service.Where(x => x.Service_Id == serviceBooking.Service.Service_Id).SingleOrDefault(); ServiceTimings Timings = db.ServiceTimings.Where(x => x.Timing_Id == serviceBooking.ServiceTimings.Timing_Id).SingleOrDefault(); serviceBooking.Service = db.Service.Where(x => x.Service_Id == serviceBooking.Service.Service_Id).SingleOrDefault(); serviceBooking.ServiceTimings = db.ServiceTimings.Where(x => x.Timing_Id == serviceBooking.ServiceTimings.Timing_Id).SingleOrDefault(); serviceBooking.ApplicationUser = db.Users.Find(User.Identity.GetUserId()); serviceBooking.Service.SeviceName = service.SeviceName; serviceBooking.Service.ServiceDesc = service.ServiceDesc; serviceBooking.Service.Service_Id = service.Service_Id; serviceBooking.ServiceTimings.Timing_Id = Timings.Timing_Id; serviceBooking.ServiceTimings.Timing = Timings.Timing; serviceBooking.ServiceTimings.Service = Timings.Service; ModelState.Clear(); TryValidateModel(serviceBooking); if (ModelState.IsValid) { serviceBooking.ApplicationUser = db.Users.Find(User.Identity.GetUserId()); db.ServiceBooking.Add(serviceBooking); db.SaveChanges(); String toEmail = serviceBooking.ApplicationUser.Email; String subject = serviceBooking.Service.SeviceName + " Booking Details"; //String contents = newsletterViewModel.News_content; String contents1 = String.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/Email_Template/Booking_Contents.html"))) { contents1 = reader.ReadToEnd(); } contents1 = contents1.Replace("CONTENT0", serviceBooking.Booking_Id.ToString()); contents1 = contents1.Replace("CONTENT1", serviceBooking.Service.SeviceName); contents1 = contents1.Replace("CONTENT2", serviceBooking.BookingDate.ToShortDateString()); contents1 = contents1.Replace("CONTENT3", serviceBooking.ServiceTimings.Timing); //contents = contents1 + contents ; EmailSender es = new EmailSender(); es.Send(toEmail, subject, contents1); return(RedirectToAction("Index")); } ViewBag.Service = new SelectList(db.Service, "Service_Id ", "SeviceName"); return(View(serviceBooking)); }
private void paymentForm_FinalizingPayment(object sender, EventArgs e) { var paymentForm = sender as PointOfSalesModule.Payment.Create; _serviceBooking = _presenter.Save(); if (paymentForm == null) { return; } paymentForm.Transaction = _serviceBooking; }
// GET: ServiceBookings/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceBooking serviceBooking = db.ServiceBooking.Find(id); if (serviceBooking == null) { return(HttpNotFound()); } return(View(serviceBooking)); }
public async Task <ActionResult <ServiceBooking> > PostServiceBooking(ServiceBooking serviceBooking) { var session = await GetSession(); if (session == null) { return(BadRequest()); } serviceBooking.UserId = session.UserId; _context.ServiceBookings.Add(serviceBooking); await _context.SaveChangesAsync(); return(CreatedAtAction("GetServiceBooking", new { id = serviceBooking.Id }, serviceBooking)); }
//ServiceBooking code Start #region ServiceBooking public ActionResult CreateBooking(int costumerId) { var Costumer = db.Costumers.Find(costumerId); ViewBag.costumer = Costumer; ViewBag.CostumerId = new SelectList(db.Costumers, "Id", "Name"); ViewBag.ServicedBy = new SelectList(db.Employees.Where(x => (x.EmployeeTypeId == 1) && (x.Status == 1)), "Id", "Name"); var model = new ServiceBooking { CostumerId = Costumer.Id }; return(View(model)); }
public ActionResult CreateBooking(ServiceBooking model) { List <string> errors = new List <string>(); try { model.Status = (int)DataStatus.Active; model.EntryBy = Utility.Currentuser.Id; model.EntryDate = DateTime.Now; if (ModelState.IsValid) { db.ServiceBookings.Add(model); db.SaveChanges(); return(RedirectToAction("CreateBooking", new { costumerid = model.CostumerId })); } foreach (var item in ModelState.Where(x => x.Value.Errors.Any())) { errors.Add(item.Value.Errors.FirstOrDefault().ErrorMessage); } } catch (Exception ex) { errors.Add(ex.Message); } if (errors.Count > 0) { TempData["Errors"] = errors; } ViewBag.CostumerId = new SelectList(db.Costumers, "Id", "Name"); ViewBag.ServicedBy = new SelectList(db.Employees.Where(x => (x.EmployeeTypeId == 2) && (x.Status == 1)), "Id", "Name"); //ViewBag.ServicedBy = new SelectList(db.Employees, "Id", "Name"); return(View(model)); }
public ActionResult EditBooking(ServiceBooking model) { List <string> errors = new List <string>(); try { var _oldmodel = db.ServiceBookings.Find(model.Id); _oldmodel.VehicleNumber = model.VehicleNumber; _oldmodel.ServicedBy = model.ServicedBy; _oldmodel.ServicedDate = model.ServicedDate; _oldmodel.NextServiceDate = model.NextServiceDate; if (ModelState.IsValid) { db.Entry(_oldmodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("CreateBooking", new { costumerid = model.CostumerId })); } foreach (var item in ModelState.Where(x => x.Value.Errors.Any())) { errors.Add(item.Value.Errors.FirstOrDefault().ErrorMessage); } } catch (Exception ex) { errors.Add(ex.Message); } if (errors.Count > 0) { TempData["Errors"] = errors; } //ViewBag.ServicedBy = new SelectList(db.Employees, "Id", "Name",model.ServicedBy); ViewBag.ServicedBy = new SelectList(db.Employees.Where(x => (x.EmployeeTypeId == 2) && (x.Status == 1)), "Id", "Name", model.ServicedBy); return(View()); }
public ServiceBooking Save() { ServiceBooking serviceBooking = null; var session = NHibernateSessionManager.GetLocalSession(); session.DoTransactional(sess => { serviceBooking = new ServiceBooking( _form.Customer, _form.VehicleRegistration, DateTime.Now.AddDays(10) ); foreach (var serviceBookingDto in _form.ServiceBookingDtos) { serviceBooking.AddBookingItem(serviceBookingDto.Service, serviceBookingDto.Price); } serviceBooking = _serviceBookingRepository.Insert(serviceBooking); }); return serviceBooking; }
public ServiceBooking Save() { ServiceBooking serviceBooking = null; var session = NHibernateSessionManager.GetLocalSession(); session.DoTransactional(sess => { serviceBooking = new ServiceBooking( _form.Customer, _form.VehicleRegistration, DateTime.Now.AddDays(10) ); foreach (var serviceBookingDto in _form.ServiceBookingDtos) { serviceBooking.AddBookingItem(serviceBookingDto.Service, serviceBookingDto.Price); } serviceBooking = _serviceBookingRepository.Insert(serviceBooking); }); return(serviceBooking); }
public ActionResult CancelBooking(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceBooking serviceBooking = db.ServiceBooking.Find(id); if (serviceBooking == null) { return(HttpNotFound()); } serviceBooking.BookingStatus = false; if (ModelState.IsValid) { db.Entry(serviceBooking).State = EntityState.Modified; db.SaveChanges(); String toEmail = serviceBooking.ApplicationUser.Email; String subject = serviceBooking.Service.SeviceName + " Booking Cancellation Details"; //String contents = newsletterViewModel.News_content; String contents1 = String.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/Email_Template/Cancel_Contents.html"))) { contents1 = reader.ReadToEnd(); } contents1 = contents1.Replace("CONTENT0", serviceBooking.Booking_Id.ToString()); contents1 = contents1.Replace("CONTENT1", serviceBooking.Service.SeviceName); contents1 = contents1.Replace("CONTENT2", serviceBooking.BookingDate.ToShortDateString()); contents1 = contents1.Replace("CONTENT3", serviceBooking.ServiceTimings.Timing); //contents = contents1 + contents ; EmailSender es = new EmailSender(); es.Send(toEmail, subject, contents1); return(RedirectToAction("Index")); } return(View(serviceBooking)); }
public AdminBookingController() { myService = new ServiceBooking(); serviceInvoice = new ServiceInvoice(); }
public BookingController() { myService = new ServiceBooking(); ServiceCar = new ServiceCar(); ServiceClient = new ServiceUser(); }
private void paymentForm_FinalizingPayment(object sender, EventArgs e) { var paymentForm = sender as PointOfSalesModule.Payment.Create; _serviceBooking = _presenter.Save(); if (paymentForm == null) return; paymentForm.Transaction = _serviceBooking; }
private void AssertBooking(ServiceBooking booking, int?studentCapacity, bool?isOnlineBookable) { Assert.That(booking, Is.Not.Null); Assert.That(booking.studentCapacity, Is.EqualTo(studentCapacity)); Assert.That(booking.isOnlineBookable, Is.EqualTo(isOnlineBookable)); }
public ResModel AddServiceBooking(ServiceBookingDto serviceBookingDto, UserDto operationUser) { using (var db = new ModelContext()) { var billNo = ""; var lastIndex = 0; var dateFormat = ""; var index = 0; var indexStr = ""; var bookingBill = db.BillNoSetting.FirstOrDefault(i => i.Name == BillTypeName.预约单号.ToString()); if (bookingBill.DailyReset) { var lastBooking = db.ServiceBooking.Where(i => i.CreateTime.Value.Day == DateTime.Now.Day).OrderByDescending(i => i.CreateTime).FirstOrDefault(); lastIndex = lastBooking?.BillNoIndex ?? 0; } else { var lastBooking = db.ServiceBooking.OrderByDescending(i => i.CreateTime).FirstOrDefault(); lastIndex = lastBooking?.BillNoIndex ?? 0; } index = lastIndex + 1; indexStr = index.ToString(); switch (bookingBill.SerNoLength) { case BillSerNoLength.两位: indexStr = indexStr.PadLeft(2, '0'); break; case BillSerNoLength.位: indexStr = indexStr.PadLeft(3, '0'); break; case BillSerNoLength.四位: indexStr = indexStr.PadLeft(4, '0'); break; case BillSerNoLength.五位: indexStr = indexStr.PadLeft(5, '0'); break; case BillSerNoLength.六位: indexStr = indexStr.PadLeft(6, '0'); break; } switch (bookingBill.DateFormat) { case BillDateFormat.简洁年月日: dateFormat = DateTime.Now.ToString("yyMMdd"); break; case BillDateFormat.完整年月日: dateFormat = DateTime.Now.ToString("yyyyMMdd"); break; case BillDateFormat.无: dateFormat = ""; break; } billNo = bookingBill.Prefix + dateFormat + indexStr; var serviceBooking = new ServiceBooking() { Id = Guid.NewGuid(), BillNo = billNo, BillNoIndex = index, BookingCreateTime = DateTime.Now, ServiceBookingState = ServiceBookingState.待接车, ServiceRepairTime = serviceBookingDto.ServiceRepairTime, CarId = serviceBookingDto.CarId, ContactName = serviceBookingDto.ContactName, ContactPhone = serviceBookingDto.ContactPhone, ContactAddress = serviceBookingDto.ContactAddress, CompanyName = serviceBookingDto.CompanyName, ServiceAdvisorId = serviceBookingDto.ServiceAdvisorId, RepairTypeId = serviceBookingDto.RepairTypeId, CustomerDescription = serviceBookingDto.CustomerDescription, RepairDescription = serviceBookingDto.RepairDescription, Remark = serviceBookingDto.Remark, CreateTime = DateTime.Now }; var estimateRepairParts = serviceBookingDto.EstimateRepairParts.Select(i => new EstimateRepairParts() { Id = Guid.NewGuid(), PartsId = i.PartsId, ServiceAccountTypeId = i.ServiceAccountTypeId, ServiceBookingId = serviceBooking.Id, Count = i.Count, Price = i.Price }); var serviceRepairItem = serviceBookingDto.ServiceRepairItem.Select(i => new ServiceRepairItem() { Id = Guid.NewGuid(), RepairItemId = i.RepairItemId, WorkHour = i.WorkHour, Price = i.Price, ServiceBookingId = serviceBooking.Id, ServiceAccountTypeId = i.ServiceAccountTypeId, Description = i.Description }); using (var scope = new TransactionScope()) { try { db.ServiceBooking.Add(serviceBooking); db.SaveChanges(); db.EstimateRepairParts.AddRange(estimateRepairParts); db.ServiceRepairItem.AddRange(serviceRepairItem); db.SaveChanges(); scope.Complete(); } catch (Exception e) { return(new ResModel() { Msg = "添加添加失败", Success = false }); } return(new ResModel() { Msg = "添加添加成功", Success = true }); } } }