public ActionResult EditPerson(FormCollection fc, int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tOsoby person = service.GetPersonData(id.Value); try { if (TryUpdateModel(person, "") && TryUpdateModel(person.tAdresy, "tAdresy")) { if (CheckPasswords(fc, service.GetClient(person.IDKlienta))) { if (ModelState.IsValid) { service.ChangePersonData(person); if (ChangePassword(fc["OldPassword"], fc["NewPassword"], person.IDKlienta)) { service.Save(); ViewBag.Message = "Data saved successfully."; } } } } } catch (Exception ex) { HandleEditionException(ex); } CreateAddressCountryList(fc); return(View(person)); }
public void UpdatePerson(tOsoby person, ITravelAgencyService service) { person.NIP = NIP.Text; person.Imie = FirstName.Text; person.Nazwisko = Surname.Text; Address.UpdateAddress(person.tAdresy, service); }
public ActionResult Edit() { int?userId = service.GetClientId(User.Identity.Name); if (userId.HasValue) { CreateAddressCountryList(null); tFirmy firm = service.GetFirmData(userId.Value); if (firm != null) { return(View("EditFirm", firm)); } else { tOsoby person = service.GetPersonData(userId.Value); if (person == null) { return(RedirectToAction("Login")); } else { return(View("EditPerson", person)); } } } return(View()); }
public void CreatePerson(tOsoby person, tAdresy address, string email) { var client = GetNonNullClientId(email); person.IDKlienta = client.IDKlienta; person.tKlient = client; person.tAdresy = address; context.tOsoby.Add(person); }
public void AssignData(tOsoby person) { ClientId.Value = person.tKlient.IDKlienta.ToString(); NIP.Text = person.NIP; FirstName.Text = person.Imie; Surname.Text = person.Nazwisko; Address.AssignData(person.tAdresy); LoginData.AssignData(person.tKlient); }
/// <summary> /// Returns person data prior to the modification. /// </summary> /// <returns>the person data object</returns> private tOsoby GetPersonData() { int?userId = service.GetClientId(User.Identity.Name); if (userId.HasValue) { tOsoby person = service.GetPersonData(userId.Value); return(person); } return(null); }
private void AssignData() { tOsoby person = GetPersonData(); if (person != null) { IsPerson = true; PersonData.AssignData(person); } else { tFirmy firm = GetFirmData(); if (firm != null) { IsFirm = true; FirmData.AssignData(firm); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AssignData(); } else { tOsoby person = GetPersonData(); if (person != null) { IsPerson = true; } else { IsFirm = GetFirmData() != null; } } PersonData.Visible = IsPerson; FirmData.Visible = !IsPerson; }
public static void AddUserToRole(String userName) { var service = new TravelAgencyService(); int?userid = service.GetClientId(userName); if (userid != null) { tOsoby person = service.GetPersonData(userid.Value); if (person != null) { String roleName = person.bPracownik ? ADMIN_ROLE : CLIENT_ROLE; if (!Roles.IsUserInRole(userName, roleName)) { if (Roles.GetAllRoles().Where(r => r == roleName).FirstOrDefault() == null) { Roles.CreateRole(roleName); } Roles.AddUserToRole(userName, roleName); } } } }
public void CreatePerson(tOsoby person, tAdresy address, string email) { unitOfWork.CreatePerson(person, address, email); }
public void ChangePersonData(tOsoby person) { unitOfWork.ChangePersonData(person); }
public void ChangePersonData(tOsoby person) { context.tOsoby.Attach(person); context.Entry(person).State = EntityState.Modified; context.Entry(person.tAdresy).State = EntityState.Modified; }