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 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); } }