private Login GetUser() { var email = Session["email"]; var loginData = HttpHelper.Get<LoginData>(string.Format(serviceBaseUri + "/Login?username={0}", email)); mapper = new AutoDataContractMapper(); var login = new Login(); mapper.Map(loginData, login); return login; }
public ActionResult Save(LoginInputModel loginInputModel) { var loginToUpdate = new Login(); loginToUpdate.CreatedDateTime = loginInputModel.CreatedDateTime; loginToUpdate.CreatedBy = loginInputModel.CreatedBy; loginToUpdate.Password = loginInputModel.Password; loginToUpdate.IsAdmin = loginInputModel.IsAdmin; loginToUpdate.Id = loginInputModel.Id; loginToUpdate.Email = new Email { Address = (string)Session["email"] }; var mapper = new AutoDataContractMapper(); var loginData = new LoginData(); mapper.Map(loginToUpdate, loginData); var data = HttpHelper.Put(string.Format(serviceBaseUri + "/Login/{0}", loginInputModel.Id), loginData); var savedLogin = new Login(); mapper.Map(data, savedLogin); return PartialView(GetUser()); }
public ActionResult Edit(int id, int emailType) { var email = new Email(); var constituentId = Convert.ToInt32(Session["constituentId"]); TryUpdateModel(email); email.Type = new EmailType() { Id = emailType }; email.Constituent = new Constituent { Id = constituentId }; mapper = new AutoDataContractMapper(); var emailData = new EmailData(); mapper.Map(email, emailData); HttpHelper.Put(string.Format(serviceBaseUri+"/Emails/{0}",id), emailData); return PartialView(new GridModel(GetEmails())); }
public ActionResult Edit(int id, int positionType, int constiuent) { var committee = new Committee(); TryUpdateModel(committee); committee.Type = new PositionType() { Id = positionType }; committee.Constituent = new Constituent { Id = constiuent }; mapper = new AutoDataContractMapper(); var committeeData = new CommitteeData(); mapper.Map(committee, committeeData); HttpHelper.Put(string.Format(serviceBaseUri + "/Committees/{0}", id), committeeData); return PartialView(new GridModel(GetCommitteeMembers())); }
public void ShouldUpdateConstituentName() { var constituent = new TestDataHelper().CreateConstituent(ConstituentMother.ConstituentWithName(ConstituentNameMother.JamesFranklin())); constituent.Name.FirstName = "John"; constituent.Name.LastName = "Smith"; var mapper = new AutoDataContractMapper(); var nameData = new ConstituentNameData(); mapper.Map(constituent.Name, nameData); var constituentName = HttpHelper.Put(string.Format("{0}/{1}", baseUri, nameData.Id), nameData); Assert.IsNotNull(constituentName); Assert.That(constituentName.FirstName, Is.EqualTo("John")); Assert.That(constituentName.LastName, Is.EqualTo("Smith")); }
public ActionResult Insert(string lastUpload) { var uploadModel = new UploadModel(); TryUpdateModel(uploadModel); var constituentId = Convert.ToInt32(Session["loggedInConstituentId"]); uploadModel.Constituent = new Constituent { Id = constituentId }; mapper = new AutoDataContractMapper(); var uploadData = new UploadData(); mapper.Map(uploadModel, uploadData); HttpHelper.Post(string.Format(serviceBaseUri + "/UploadFiles"), uploadData); return View(new GridModel(Model)); }
public ActionResult Save(ConstituentInputModel constituent) { var constituentToSave = new Constituent(); constituentToSave.Name = new ConstituentName() { Id = constituent.NameId, FirstName = constituent.FirstName, MiddleName = constituent.MiddleName, LastName = constituent.LastName, CreatedBy = constituent.CreatedBy, CreatedDateTime = constituent.CreatedDateTime, PreferedName = "temp", Salutation = new SalutationType() { Id = 1 } }; constituentToSave.HouseName = constituent.HouseName; constituentToSave.BranchName = new BranchType { Id = constituent.BranchName }; constituentToSave.Gender = constituent.Gender; constituentToSave.MaritialStatus = constituent.MaritalStatus; constituentToSave.HasExpired = constituent.HasExpired; constituentToSave.IsRegistered = constituent.IsRegistered; constituentToSave.CreatedDateTime = constituent.CreatedDateTime; constituentToSave.CreatedBy = constituent.CreatedBy; constituentToSave.BornOn = constituent.BornOn; constituentToSave.Id = Convert.ToInt32(Session["constituentId"]); var mapper = new AutoDataContractMapper(); var constituentData = new ConstituentData(); mapper.Map(constituentToSave, constituentData); ConstituentData data = HttpHelper.Put(string.Format(serviceBaseUri + "/Constituents/{0}", Session["constituentId"]), constituentData); var savedConstituent = new Constituent(); mapper.Map(data, savedConstituent); return PartialView(GetConstituent()); }
public ActionResult Edit(int id, int OccupationType) { var Occupation = new Occupation(); TryUpdateModel(Occupation); var constituentId = Convert.ToInt32(Session["constituentId"]); Occupation.Type = new OccupationType {Id = OccupationType}; Occupation.Address = new Address() {Id = 1}; Occupation.Constituent = new Constituent {Id = constituentId}; mapper = new AutoDataContractMapper(); var OccupationData = new OccupationData(); mapper.Map(Occupation, OccupationData); HttpHelper.Put(string.Format(serviceBaseUri+"/Occupations/{0}",id), OccupationData); return PartialView(new GridModel(GetOccupations())); }
public ActionResult Edit(int id, int PhoneType,int ShortAddress) { var phone = new Phone(); var constituentId = Convert.ToInt32(Session["constituentId"]); TryUpdateModel(phone); phone.Type = new PhoneType {Id = PhoneType}; phone.Constituent = new Constituent {Id = constituentId}; phone.Address = new ShortAddress() {Id = ShortAddress}; mapper = new AutoDataContractMapper(); var phoneData = new PhoneData(); mapper.Map(phone, phoneData); HttpHelper.Put(string.Format(serviceBaseUri+"/Phones/{0}",id), phoneData); return PartialView(new GridModel(GetPhones())); }
public ActionResult Edit(int id, int associationType, int constiuent) { var association = new Association(); var constituentId = Convert.ToInt32(Session["loggedInConstituentId"]); TryUpdateModel(association); association.Type = new AssociationType {Id = associationType}; association.Constituent = new Constituent {Id =constituentId }; association.AssociatedConstituent = new Constituent() { Id = constiuent }; mapper = new AutoDataContractMapper(); var associationData = new AssociationData(); mapper.Map(association, associationData); HttpHelper.Put(string.Format(serviceBaseUri+"/Associations/{0}", id), associationData); return PartialView(new GridModel(GetAssociations( Convert.ToInt32(Session["loggedInConstituentId"])))); }
public ActionResult Create(int educationType) { var educationDetail = new EducationDetail(); TryUpdateModel(educationDetail); var constituentId = Convert.ToInt32(Session["constituentId"]); educationDetail.Constituent = new Constituent { Id = constituentId}; educationDetail.Type = new EducationType() { Id = educationType }; mapper = new AutoDataContractMapper(); var educationDetailData = new EducationDetailData(); mapper.Map(educationDetail, educationDetailData); HttpHelper.Post(string.Format(serviceBaseUri+"/EducationDetails?ConstituentId={0}", constituentId), educationDetailData); return PartialView(new GridModel(GetEducations())); }
public ActionResult Create(int associationType, int constiuent) { var association = new Association(); TryUpdateModel(association); var constituentId = Convert.ToInt32(Session["loggedInConstituentId"]); if (association.AssociatedConstituentId <= 0) association.AssociatedConstituent = null; association.AssociatedConstituent = new Constituent() { Id = constiuent }; association.Constituent = new Constituent(){Id = constituentId}; association.Type = new AssociationType { Id = associationType }; mapper = new AutoDataContractMapper(); var associationData = new AssociationData(); mapper.Map(association, associationData); HttpHelper.Post(serviceBaseUri+"/Associations?ConstituentId="+constituentId, associationData); return PartialView(new GridModel(GetAssociations( Convert.ToInt32(Session["loggedInConstituentId"])))); }
private Constituent GetConstituent() { var constituentId = Convert.ToInt32(Session["constituentId"]); var constituentData = HttpHelper.Get<ConstituentData>(string.Format(serviceBaseUri+"/Constituents/{0}", constituentId)); mapper = new AutoDataContractMapper(); var constituent = new Constituent(); mapper.Map(constituentData, constituent); constituent.MaritialStatusString = constituent.MaritialStatus == 1 ? "Married" : "Single"; return constituent; }