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 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 JsonResult CreateMemberRegister(tblUserInformation objUser) { Dictionary<string, object> res = new Dictionary<string, object>(); try { using (var db = new TestEntity()) { Membership.ApplicationName = "/"; Membership.CreateUser(objUser.Phone.ToString(), objUser.Phone.ToString()); MembershipUser user = Membership.GetUser(objUser.Phone.ToString()); Roles.ApplicationName = "/"; if (!Roles.RoleExists("Customer")) { Roles.CreateRole("Customer"); Roles.AddUserToRole(objUser.Phone.ToString(), "Customer"); } else { Roles.AddUserToRole(objUser.Phone.ToString(), "Customer"); } tblUserInformation objmember = new tblUserInformation(); objmember.idUser = new Guid(user.ProviderUserKey.ToString()); objmember.FirstName = objUser.FirstName; objmember.LastName = objUser.LastName; objmember.Phone = objUser.Phone.ToString(); objmember.DOB = objUser.DOB; objmember.IsActive = true; objmember.IsCompleted = true; objmember.IsNotify = false; objmember.CreatedBy = User.Identity.Name; objmember.CreatedDatetime = DateTime.Now; db.tblUserInformations.Add(objmember); db.SaveChanges(); FormsAuthentication.SetAuthCookie(objUser.Phone.ToString(), false); Session["Username"] = null; Session["LanguageId"] = null; if (Session["Username"] == null) { Session["Username"] = objUser.FirstName + " " + objUser.LastName; } res["success"] = 1; } } catch (Exception ex) { res["error"] = 2; res["message"] = ex.Message.ToString(); } return Json(res, JsonRequestBehavior.AllowGet); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblUserInformation tblUserInformation = db.tblUserInformations.Find(id); db.tblUserInformations.Remove(tblUserInformation); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblUserInformation tblUserInformation = db.tblUserInformations.Find(id); var config = new MapperConfiguration(x => { x.CreateMap <tblUserInformation, UserInformationViewModel>(); }); var _mapper = config.CreateMapper(); UserInformationViewModel userinfo = _mapper.Map <UserInformationViewModel>(tblUserInformation); return(View(userinfo)); }
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 Edit(UserInformationViewModel userinfo) { if (ModelState.IsValid) { //insert gar //converting view model to entity model var config = new MapperConfiguration(x => { x.CreateMap <UserInformationViewModel, tblUserInformation>(); }); var _mapper = config.CreateMapper(); tblUserInformation entitymodel = _mapper.Map <tblUserInformation>(userinfo); //update database db.Entry(entitymodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userinfo)); }
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 })); }