protected void ConfirmButton_Click(object sender, EventArgs e) { int offerId; if (int.TryParse(OfferId.Value, out offerId)) { var offer = service.FindOffer(offerId); if (offer != null) { int?userId = AuthorizeUtil.GetUserId(service, User); if (userId == null) { Response.Redirect("~/Account/Login"); } pnlConfirm.Visible = false; if (!IsOfferReserved(offerId)) { tKlient client = service.GetClientWithPersons(userId.Value); int personId = client.tOsoby.First().IDOsoby; service.ReserveOffer(offerId, personId, client.IDKlienta); } Message.Text = "Offer has been reserved."; } } }
public ActionResult Reserve(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tOferta tOferta = service.FindOffer(id.Value); if (tOferta == null) { return(HttpNotFound()); } int?userId = AuthorizeUtil.GetUserId(service, User); if (userId == null) { return(RedirectToAction("Login", "Account")); } tKlient client = service.GetClientWithPersons(userId.Value); int personId = client.tOsoby.First().IDOsoby; ViewBag.IsReserved = IsOfferReserved(id.Value); return(View(new ReservationModel { Offer = tOferta, ClientWithPersons = client, PersonId = personId })); }
protected void ConfirmButton_Click(object sender, EventArgs e) { int attractionId; if (int.TryParse(AttractionId.Value, out attractionId)) { var attraction = service.FindAttraction(attractionId); if (attraction != null) { if (IsOfferReserved(attraction.IDAtrakcjiUslugi)) { int?userId = AuthorizeUtil.GetUserId(service, User); if (userId == null) { Response.Redirect("~/Account/Login"); } pnlConfirm.Visible = false; if (!IsAttractionReserved(attractionId)) { tKlient client = service.GetClientWithPersons(userId.Value); int personId = client.tOsoby.First().IDOsoby; service.ReserveAttraction(attractionId, personId, client.IDKlienta); } Message.Text = "Offer has been reserved."; } else { pnlConfirm.Visible = false; Message.Text = "Offer related to this attraction has to be reserved first."; } } } }
public ActionResult Reserve(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tAtrakcjeUslugi attraction = service.FindAttraction(id.Value); if (attraction == null) { return(HttpNotFound()); } int?userId = AuthorizeUtil.GetUserId(service, User); if (userId == null) { return(RedirectToAction("Login", "Account")); } tKlient client = service.GetClientWithPersons(userId.Value); int personId = client.tOsoby.First().IDOsoby; ConfigureViewBag(attraction, userId); return(View(new ReservationModel { Attraction = attraction, ClientWithPersons = client, PersonId = personId })); }
public ClientData GetClientData(String clientId) { ClientData data = null; int intId; if (!int.TryParse(clientId, out intId)) { return(null); } tKlient single = unitOfWork.ClientRepository.Get(c => c.IDKlienta == intId, null, "tFirmy,tOsoby").SingleOrDefault(); var person = single.tOsoby.SingleOrDefault(); if (person != null) { String dispaly = String.Format("{0} {1} ({2}", person.Imie, person.Nazwisko, single.email); String role = person.bPracownik ? "Admin" : "User"; data = new ClientData(intId, role, dispaly, person.tAdresy, single.haslo); } else { var firm = single.tFirmy.SingleOrDefault(); if (firm != null) { String dispaly = String.Format("{0} ({1}", firm.NazwaFirmy, single.email); data = new ClientData(intId, "User", dispaly, firm.tAdresy, single.haslo); } } return(data); }
private bool CheckPassword(ChangePasswordData cd, tKlient client) { List <String> errorList = new List <String>(2); var res = WebDataHelper.CheckPasswords(cd.OldPassword, cd.NewPassword, cd.NewPassword2, client, errorList); errorList.ForEach(e => ModelState.AddModelError("", e)); return(res); }
public ActionResult DeleteConfirmed(int id) { tKlient tKlient = db.tKlient.Find(id); db.tKlient.Remove(tKlient); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Imya,Familiya,ID_Klient,Data_zaseleniya,Data_viseleniya")] tKlient tKlient) { if (ModelState.IsValid) { db.Entry(tKlient).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tKlient)); }
public ActionResult Create([Bind(Include = "Imya,Familiya,ID_Klient,Data_zaseleniya,Data_viseleniya")] tKlient tKlient) { if (ModelState.IsValid) { db.tKlient.Add(tKlient); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tKlient)); }
public bool IsAttractionReserved(int attractionId, object sessionUserId) { int?userId = sessionUserId as int?; if (userId == null) { return(false); } tKlient client = GetClientWithPersons(userId.Value); return(IsAttractionReserved(attractionId, client.tOsoby.First().IDOsoby, userId.Value)); }
private bool IsAttractionReserved(int attrId) { int?userId = AuthorizeUtil.GetUserId(service, User); if (userId == null) { return(false); } tKlient client = service.GetClientWithPersons(userId.Value); return(service.IsAttractionReserved(attrId, client.tOsoby.First().IDOsoby, userId.Value)); }
// GET: tKlients/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tKlient tKlient = db.tKlient.Find(id); if (tKlient == null) { return(HttpNotFound()); } return(View(tKlient)); }
public bool TryLogin(string login, string password, out ClientData clientData) { clientData = null; tKlient single = unitOfWork.ClientRepository.Get(c => c.email == login, null).SingleOrDefault(); if (single != null) { string encoded = DataUtil.GetMd5Hash(password); if (encoded.Equals(single.haslo)) { clientData = GetClientData(single.IDKlienta.ToString()); if (clientData != null) { return(true); } } } return(false); }
private bool CheckPasswords(FormCollection fc, tKlient cd) { bool isValid = true; if (!String.IsNullOrEmpty(fc["NewPassword"]) || !String.IsNullOrEmpty(fc["OldPassword"]) || !String.IsNullOrEmpty(fc["NewPassword2"])) { if (fc["NewPassword"] != fc["NewPassword2"]) { ViewBag.NewPassword2Error = "Passwords do not match."; isValid = false; } // Old password must not be chacked here since the WebSecurity carries about that. if (fc["NewPassword"].Length < 8) { ViewBag.NewPasswordError = "New password is too short."; isValid = false; } } return(isValid); }
public static bool CheckPasswords(String oldPassword, String newPassword, String newPassword2, tKlient client, List <String> errorList) { bool isValid = true; if (!String.IsNullOrEmpty(newPassword) || !String.IsNullOrEmpty(oldPassword) || !String.IsNullOrEmpty(newPassword2)) { if (newPassword != newPassword2) { errorList.Add("Passwords do not match."); isValid = false; } // Old password must not be chacked here since the WebSecurity carries about that. if (newPassword.Length < 8) { errorList.Add("New password is too short."); isValid = false; } } return(isValid); }