public ActionResult Create(UserInformationViewModel userinfo) { if (ModelState.IsValid) { //insert gar //converting view model to entity model tblUserInformation tblUserInformation = new tblUserInformation(); tblUserInformation.FirstName = userinfo.FirstName; tblUserInformation.LastName = userinfo.LastName; tblUserInformation.Email = userinfo.Email; tblUserInformation.Password = Cryptography.Encrypt(userinfo.Password); tblUserInformation.PhoneNo = userinfo.PhoneNo; tblUserInformation.Address = userinfo.Address; tblUserInformation.City = userinfo.City; tblUserInformation.Country = userinfo.Country; tblUserInformation.PostalCode = userinfo.PostalCode; tblUserInformation.ProfileImage = userinfo.ProfileImage; tblUserInformation.UserTypeID = 2; db.tblUserInformations.Add(tblUserInformation); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userinfo)); }
public IHttpActionResult PuttblUser(string id, tblUser tblUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblUser.UserID) { return(BadRequest()); } db.Entry(tblUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(FlightViewModel flightinfo) { if (ModelState.IsValid) { //insert gar //converting view model to entity model tblFlight dbFlight = new tblFlight(); dbFlight.FlightNo = flightinfo.FlightNo; dbFlight.Detail = flightinfo.Detail; dbFlight.FlightName = flightinfo.FlightName; if (flightinfo.FileFlightLogo != null) { var fileName = dbFlight.FlightNo + ".jpg"; var path = Server.MapPath("~/FlightImages"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } flightinfo.FileFlightLogo.SaveAs(path + "/" + fileName); dbFlight.FlightLogo = fileName; } db.tblFlights.Add(dbFlight); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(flightinfo)); }
public ActionResult Create(FlightScheduleViewModel vmFlightSchedule) { vmFlightSchedule.ListFlight = (from c in db.tblFlights.ToList() select new SelectListItem { Text = c.FlightNo, Value = c.ID.ToString() }).ToList(); vmFlightSchedule.ListRoute = (from c in db.tblRoutes.ToList() select new SelectListItem { Text = c.Departure + '-' + c.Arrival, Value = c.ID.ToString() }).ToList(); if (ModelState.IsValid) { if (IsValid(vmFlightSchedule)) { tblFlightSchedule schedule = new tblFlightSchedule(); schedule.FlightID = vmFlightSchedule.FlightID; schedule.RouteID = vmFlightSchedule.RouteID; schedule.ArrivalDateTime = vmFlightSchedule.ArrivalDateTime.Value; schedule.DepartureDateTime = vmFlightSchedule.DepartureDateTime.Value; db.tblFlightSchedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(vmFlightSchedule)); }
public IHttpActionResult PosttblUser(tblUser tblUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <proc_UserDetails1_Result> user = new List <proc_UserDetails1_Result>(); foreach (var item in db.proc_UserDetails1()) { user.Add(item); } foreach (var item in user) { if (item.Email == tblUser.Email) { return(Ok("Contains")); } } db.proc_UserRegisteration1(tblUser.Title, tblUser.FirstName, tblUser.LastName, tblUser.DOB, tblUser.PhoneNo, tblUser.Email, tblUser.Password, tblUser.Security); // db.proc_UserRegisteration(tblUser.Title, tblUser.FirstName, tblUser.LastName, tblUser.DOB, tblUser.PhoneNo, tblUser.Email, tblUser.Password); //db.tblUsers.Add(tblUser); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblUser.UserID }, tblUser)); }
public ActionResult Create(RegisterUserViewModel registerUser) { if (ModelState.IsValid) { //insert gar //converting view model to entity model tblUserInformation tblUserInformation = new tblUserInformation(); tblUserInformation.FirstName = registerUser.FirstName; tblUserInformation.LastName = registerUser.LastName; tblUserInformation.Email = registerUser.Email; tblUserInformation.Password = Cryptography.Encrypt(registerUser.Password); tblUserInformation.PhoneNo = registerUser.PhoneNo; tblUserInformation.Address = registerUser.Address; tblUserInformation.City = registerUser.City; tblUserInformation.Country = registerUser.Country; tblUserInformation.PostalCode = registerUser.PostalCode; tblUserInformation.ProfileImage = registerUser.ProfileImage; tblUserInformation.UserTypeID = 3; db.tblUserInformations.Add(tblUserInformation); db.SaveChanges(); return(RedirectToAction("Login", "Account")); } return(View(registerUser)); }
public ActionResult Create(RouteViewModel route) { if (ModelState.IsValid) { tblRoute tblRoute = new tblRoute(); tblRoute.Departure = route.Departure; tblRoute.Arrival = route.Arrival; tblRoute.DepartureShort = route.DepartureShort; tblRoute.ArrivalShort = route.ArrivalShort; db.tblRoutes.Add(tblRoute); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(route)); }
public IHttpActionResult PuttblUser(string id, tblUser tblUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if (id != tblUser.UserID) //{ // return BadRequest(); // db.proc_updateUser2(tblUser.Email, tblUser.Password); // db.Entry(tblUser).State = EntityState.Modified; db.SaveChanges(); return(Ok("updated")); }
public ActionResult Create(FlightFareViewModel vmflightFare) { if (ModelState.IsValid) { tblFare fare = new tblFare(); fare.FlightID = vmflightFare.FlightID; fare.RouteID = vmflightFare.RouteID; fare.ClassID = vmflightFare.ClassID; fare.PassengerTypeID = vmflightFare.PassengerTypeID; fare.Amount = vmflightFare.Amount; fare.AllowedBaggage = vmflightFare.AllowedBaggage; db.tblFares.Add(fare); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vmflightFare)); }
public ActionResult Delete(int bookId) { var booking = db.tblFlightBooks.Where(c => c.ID == bookId).FirstOrDefault(); if (booking != null) { db.tblFlightBooks.Remove(booking); db.SaveChanges(); } return(RedirectToAction("Index", "MyBooking")); }
public IHttpActionResult Puttbl_FlightDetails(string id, proc_ShowFlight_Result flight) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != flight.FlightId) { return(BadRequest()); } db.proc_EditFlight(id, flight.FlightStatus); //db.Entry(flight).State = EntityState.Modified; db.SaveChanges(); return(Ok(flight)); }
public ActionResult ChangePassword(ChangePasswordViewModel cpViewModel) { if (ModelState.IsValid) { tblUserInformation dbUser = db.tblUserInformations.Where(c => c.ID == cpViewModel.UserId).FirstOrDefault(); if (dbUser != null) { dbUser.Password = cpViewModel.Password; db.Entry(dbUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Login")); } } return(View(cpViewModel)); }
public ActionResult Create(FlightSeatViewModel vmFlightSeat) { vmFlightSeat.ListFlight = (from c in db.tblFlights.ToList() select new SelectListItem { Text = c.FlightNo, Value = c.ID.ToString() }).ToList(); vmFlightSeat.ListClass = (from c in db.tblClasses.ToList() select new SelectListItem { Text = c.Class, Value = c.ID.ToString() }).ToList(); if (ModelState.IsValid) { //insert //converting view model to entity model try { tblFlightSeat dbFlightSeat = new tblFlightSeat(); dbFlightSeat.FlightID = vmFlightSeat.FlightID; dbFlightSeat.ClassID = vmFlightSeat.ClassID; dbFlightSeat.NoOfSeat = vmFlightSeat.NoOfSeat; db.tblFlightSeats.Add(dbFlightSeat); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", "seat and class cannot be duplicated"); } } return(View(vmFlightSeat)); }
public bool CancelTickets(string tktId) { if (string.IsNullOrEmpty(tktId)) { return(false); } var dbCtx = new AirlineReservationEntities(); Ticketing_Info cnclTkt = dbCtx.Ticketing_Info.Find(tktId); if (cnclTkt == null) { return(false); } cnclTkt.status = "X"; dbCtx.SaveChanges(); return(true); }
public bool BookTickets(int schId, int fareId, int custId) { string tktId = DateTime.Now.ToString("ddMMMyyhhmmss"); try { var dbCtx = new AirlineReservationEntities(); Ticketing_Info tktInfo = new Ticketing_Info() { ticket_id = tktId, Fare_Id = fareId, cust_id = custId, schedule_id = schId, status = "C" }; dbCtx.Ticketing_Info.Add(tktInfo); int saved = dbCtx.SaveChanges(); return(saved > 0); } catch (Exception exc) { throw exc; } }
public IHttpActionResult PuttblTicket_table(sp_cancelTicket1_Result cancelticket) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if (id != cancelticket.TicketID) //{ // return BadRequest(); //} //db.sp_cancelticketStatus(id); // db.Entry(cancelticket).State = EntityState.Modified; db.sp_cancelticketStatus(cancelticket.TicketID); db.sp_cancelSeat(cancelticket.TicketID); db.SaveChanges(); //try //{ // db.SaveChanges(); //} //catch (DbUpdateConcurrencyException) //{ // if (!tblTicket_tableExists(id)) // { // return NotFound(); // } // else // { // throw; // } //} return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Booking(BookFlightViewModel bfVm) { var user = new tblUserInformation(); if (bfVm.ID > 0) { user = db.tblUserInformations.Where(c => c.ID == bfVm.ID).FirstOrDefault(); } else { user.FirstName = bfVm.FirstName; user.LastName = bfVm.LastName; user.Email = bfVm.Email; user.Password = "******"; user.UserTypeID = 4; user.PhoneNo = bfVm.PhoneNo; user.Address = bfVm.Address; user.City = bfVm.City; user.Country = bfVm.Country; user.PostalCode = bfVm.PostalCode; db.tblUserInformations.Add(user); db.SaveChanges(); } var flightBook = new tblFlightBook(); flightBook.UserID = user.ID; flightBook.TripTypeID = Convert.ToInt32(bfVm.FlightType); db.tblFlightBooks.Add(flightBook); db.SaveChanges(); List <PassengerDetailViewModel> passengerDetailList = JsonConvert.DeserializeObject <List <PassengerDetailViewModel> >(bfVm.jsonPassengerDetail); //departure foreach (var pdetail in passengerDetailList) { var flightBookDetail = new tblFlightBookDetail(); flightBookDetail.BookID = flightBook.ID; flightBookDetail.FlightScheduleID = Convert.ToInt32(bfVm.DepartureFlight); flightBookDetail.ClassID = Convert.ToInt32(bfVm.DepartureFlightClass); flightBookDetail.BookingDate = DateTime.Now; db.tblFlightBookDetails.Add(flightBookDetail); db.SaveChanges(); var passengerDetail = new tblPassengerDetail(); passengerDetail.BookFlightID = flightBookDetail.ID; passengerDetail.PassengerType = pdetail.PassengerType; passengerDetail.FirstName = pdetail.FirstName; passengerDetail.LastName = pdetail.LastName; passengerDetail.Gender = pdetail.Gender; passengerDetail.Phone = pdetail.Phone; passengerDetail.Address = pdetail.Address; db.tblPassengerDetails.Add(passengerDetail); db.SaveChanges(); if (bfVm.FlightType == "2") { var returnflightBookDetail = new tblFlightBookDetail(); returnflightBookDetail.BookID = flightBook.ID; returnflightBookDetail.FlightScheduleID = Convert.ToInt32(bfVm.ReturnFlight); returnflightBookDetail.ClassID = Convert.ToInt32(bfVm.ReturnFlightClass); returnflightBookDetail.BookingDate = DateTime.Now; db.tblFlightBookDetails.Add(returnflightBookDetail); db.SaveChanges(); var returnpassengerDetail = new tblPassengerDetail(); returnpassengerDetail.BookFlightID = returnflightBookDetail.ID; returnpassengerDetail.PassengerType = pdetail.PassengerType; returnpassengerDetail.FirstName = pdetail.FirstName; returnpassengerDetail.LastName = pdetail.LastName; returnpassengerDetail.Gender = pdetail.Gender; returnpassengerDetail.Phone = pdetail.Phone; returnpassengerDetail.Address = pdetail.Address; db.tblPassengerDetails.Add(returnpassengerDetail); db.SaveChanges(); } } return(RedirectToAction("FlightTicket", "SearchFlight", new { bookId = flightBook.ID })); }