private void sendReservationMail(int servicePId) { ServicePassenger sP = Current.Context.ServicePassenger.FirstOrDefault(d => d.Id == servicePId); User mailToUser = Current.Context.User.FirstOrDefault(f => f.Id == sP.AddUserId); vwCarList carDetail = Current.Context.vwCarList.FirstOrDefault(d => d.Id == sP.ServiceId); if (!string.IsNullOrEmpty(mailToUser.Email)) { ReservationInfo newLayout = new ReservationInfo { Name = mailToUser.Name + " " + mailToUser.Surname, DateString = ((DateTime)carDetail.DepartureDate).ToString("dd/MM/yyyy"), TimeString = carDetail.DepartureHour, Destination = carDetail.DestinationBox, Address = carDetail.Address }; string ContentMessage = ViewRenderer.RenderView("~/Views/Shared/MailLayouts/Reservation.cshtml", newLayout, ControllerContext); Mail newMail = new Mail { MailTo = mailToUser.Id, MailFrom = 1, MailContent = ContentMessage, Status = Constants.MAIL_STATUS_WAITING, MailSubject = "Rezervasyon Bilgisi" }; Current.Context.Mail.Add(newMail); Current.Context.SaveChanges(); SecimMail.MailGonder(mailToUser.Id, "Rezervasyon Bilgisi", ContentMessage, newMail.id); } }
public ActionResult CancelReservation(int ServiceId) { ServicePassenger sP = Current.Context.ServicePassenger.FirstOrDefault(d => d.AddUserId == Current.getUserId && d.ServiceId == ServiceId); CarService cS = Current.Context.CarService.FirstOrDefault(d => d.Id == ServiceId && d.DepartureDate >= DateTime.Now); if (cS != null && sP != null) { Current.Context.ServicePassenger.Remove(sP); Current.Context.SaveChanges(); } return(Redirect("/#rezervasyonlar")); }
public ActionResult DeletePassenger(int SpId) { ServicePassenger deleteService = Current.Context.ServicePassenger.FirstOrDefault(f => f.Id == SpId); try { Current.Context.ServicePassenger.Remove(deleteService); Current.Context.SaveChanges(); TempData["ErrorType"] = "Success"; TempData["Message"] = "Yolcu silme işlemi başarılı olmuştur!"; } catch (Exception) { TempData["ErrorType"] = "Fail"; TempData["Message"] = "İşlem başarısız olmuştur!"; } return(RedirectToAction("CarDetail", new { CarId = deleteService.ServiceId })); }
public ActionResult AddPassenger(ServicePassenger service) { try { service.AddUserId = Current.getUserId; service.AddTime = DateTime.Now; Current.Context.ServicePassenger.Add(service); Current.Context.SaveChanges(); TempData["ErrorType"] = "Success"; TempData["Message"] = "Yolcu başarı ile eklenmiştir!"; } catch (Exception) { TempData["ErrorType"] = "Fail"; TempData["Message"] = "Yolcu ekleme işlemi başarısız olmuştur!"; } return(RedirectToAction("CarDetail", new { CarId = service.ServiceId })); }
public ActionResult EditPassenger(ServicePassenger service) { ServicePassenger oldServicePassenger = Current.Context.ServicePassenger.FirstOrDefault(f => f.Id == service.Id); try { oldServicePassenger.Name = service.Name; oldServicePassenger.Surname = service.Surname; oldServicePassenger.TCK = service.TCK; oldServicePassenger.Phone = service.Phone; oldServicePassenger.PassengerCount = service.PassengerCount; Current.Context.SaveChanges(); TempData["ErrorType"] = "Success"; TempData["Message"] = "Yolcu güncelleme işlemi başarılı olmuştur!"; } catch (Exception) { TempData["ErrprType"] = "Fail"; TempData["Message"] = "İşlem başarısız olmuştur!"; } return(RedirectToAction("CarDetail", new { CarId = oldServicePassenger.ServiceId })); }
public ActionResult Reservation(int ServiceId, int PassengerCount) { try { CarService service = Current.Context.CarService.FirstOrDefault(d => d.Id == ServiceId); if (service != null) { ServicePassenger cService = Current.Context.ServicePassenger.FirstOrDefault(d => d.AddUserId == Current.getUserId && d.ServiceId == ServiceId); secimyolu.Models.User curUser = Current.getUser; if (cService == null) { cService = new ServicePassenger(); cService.ServiceId = ServiceId; cService.AddTime = DateTime.Now; cService.AddUserId = curUser.Id; cService.Name = curUser.Name; cService.Surname = curUser.Surname; cService.TCK = curUser.TCNo; cService.Phone = curUser.GSM; cService.PassengerCount = PassengerCount; Current.Context.ServicePassenger.Add(cService); } else { cService.PassengerCount = PassengerCount; cService.AddTime = DateTime.Now; } Current.Context.SaveChanges(); sendReservationMail(cService.Id); return(Redirect("/#rezervasyonlar")); } } catch (Exception) { } return(Redirect("/#sonuc")); }
public ActionResult Reservation(int ServiceId) { if (Current.isLogon) { vwCarList car = Current.Context.vwCarList.FirstOrDefault(d => d.DepartureDate >= DateTime.Now && d.Id == ServiceId); ServicePassenger sP = Current.Context.ServicePassenger.FirstOrDefault(d => d.ServiceId == ServiceId && d.AddUserId == Current.getUserId); int pCount = sP != null ? sP.PassengerCount : 0; if (car.Qutoa > (car.PassengerCount - pCount)) { int curQuota = (int)car.Qutoa - car.PassengerCount + pCount; ViewBag.CurQuota = curQuota > 10 ? 10 : curQuota; ViewBag.PassengerCount = pCount; return(View(car)); } else { return(null); } } else { return(null); } }