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 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 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 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 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 JsonResult Search(SearchModel searchCriteria) { var uriString = string.Format(serviceBaseUri + @"/Search?firstName={0}&lastName={1}&email={2}&phone={3}&occupationName={4}&occupationDescription={5}&instituteName={6}&instituteLocation={7}&qualification={8}&yearOfGradutation={9}&address={10}&state={11}&city={12}&country={13}&postcode={14}&preferedName={15}&houseName={16}&branch={17}&matchAllCriteria={18}" ,searchCriteria.FirstName, searchCriteria.LastName,searchCriteria.Email,searchCriteria.Phone,searchCriteria.OccupationName,searchCriteria.OccupationDescription ,searchCriteria.InstituteName,searchCriteria.InstituteLocation,searchCriteria.Qualification,searchCriteria.YearOfGraduation ,searchCriteria.Address,searchCriteria.State,searchCriteria.City,searchCriteria.Country,searchCriteria.Postcode ,searchCriteria.PreferedName,searchCriteria.HouseName,searchCriteria.Branch,true); var constituentsData = HttpHelper.Get<ConstituentsData>(uriString); mapper = new AutoDataContractMapper(); var constituents = new Constituents(); mapper.MapList(constituentsData, constituents,typeof(Constituent)); ViewData["Constituents"] = constituents; return this.Json(constituents); }
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"])))); }
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 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()); }
private Emails GetEmails() { var constituentId = Convert.ToInt32(Session["constituentId"]); var emailsData = HttpHelper.Get<EmailsData>(serviceBaseUri+"/Emails?ConstituentId="+constituentId); mapper = new AutoDataContractMapper(); var emails = new Emails(); mapper.MapList(emailsData, emails, typeof(Email)); return emails; }
private Committees GetCommitteeMembers() { var committeesData = HttpHelper.Get<CommitteesData>(serviceBaseUri+"/Committees"); mapper = new AutoDataContractMapper(); var committees = new Committees(); mapper.MapList(committeesData, committees, typeof(Committee)); return committees; }
private Constituents PopulateSearchResults(string id) { var uriString = serviceBaseUri + "/SearchUnRegistered?constituentId=" + id; var constituentsData = HttpHelper.Get<ConstituentsData>(uriString); mapper = new AutoDataContractMapper(); var constituents = new Constituents(); mapper.MapList(constituentsData, constituents, typeof (Constituent)); return constituents; }
private Constituents GetRegistrations() { var constituentsData = HttpHelper.Get<ConstituentsData>(serviceBaseUri + "/Registrations"); mapper = new AutoDataContractMapper(); var constituents = new Constituents(); mapper.MapList(constituentsData, constituents, typeof (Constituent)); return constituents; }
private Phones GetPhones(int constituentId) { var phonesData = HttpHelper.Get<PhonesData>(string.Format(serviceBaseUri + "/Phones?ConstituentId={0}", constituentId)); mapper = new AutoDataContractMapper(); var phones = new Phones(); mapper.MapList(phonesData, phones, typeof(Phone)); return phones; }
private Occupations GetOccupations(int constituentId) { var OccupationsData = HttpHelper.Get<OccupationsData>(string.Format(serviceBaseUri + "/Occupations?ConstituentId={0}", constituentId)); mapper = new AutoDataContractMapper(); var Occupations = new Occupations(); mapper.MapList(OccupationsData, Occupations, typeof(Occupation)); return Occupations; }
private EducationDetails GetEducations(int constituentId) { var educationDetailsData = HttpHelper.Get<EducationDetailsData>(string.Format(serviceBaseUri + "/EducationDetails?ConstituentId={0}", constituentId)); mapper = new AutoDataContractMapper(); var educations = new EducationDetails(); mapper.MapList(educationDetailsData, educations, typeof(EducationDetail)); return educations; }
private Associations GetAssociations(int constituentId) { var associationsData = HttpHelper.Get<AssociationsData>(string.Format(serviceBaseUri + "/Associations?ConstituentId={0}", constituentId)); mapper = new AutoDataContractMapper(); var associations = new Associations(); mapper.MapList(associationsData, associations, typeof(Association)); return associations; }
private Addresses GetAddress(int constituentId) { var addressesData = HttpHelper.Get<AddressesData>(string.Format(serviceBaseUri + "/Addresses?ConstituentId={0}", constituentId)); mapper = new AutoDataContractMapper(); var addresses = new Addresses(); mapper.MapList(addressesData, addresses, typeof(Address)); return addresses; }
public ActionResult GetConstituent(string text) { Thread.Sleep(1000); var uriString = string.Format(serviceBaseUri + @"/Search?firstName={0}&lastName={0}&email={1}&phone={1}&occupationName={1}&occupationDescription={1}&instituteName={1}&instituteLocation={1}&qualification={1}&yearOfGradutation={1}&address={1}&state={1}&city={1}&country={1}&postcode={1}&preferedName={0}&houseName={1}&branch={1}", text,null); var constituentsData = HttpHelper.Get<ConstituentsData>(uriString); mapper = new AutoDataContractMapper(); var constituents = new Constituents(); mapper.MapList(constituentsData, constituents, typeof(Constituent)); IEnumerable<Constituent> enumerable = null; if (text.HasValue()) { enumerable = constituents.Where((p) => p.Name.FirstName.StartsWith(text,true,null) || p.Name.LastName.StartsWith(text,true,null)); } IEnumerable<SelectListItem> selectList = from c in enumerable select new SelectListItem { Text = c.Name.NameWithoutSalutation, Value = c.Id.ToString() }; return new JsonResult { Data = selectList }; }
private UploadFilesModel GetFiles() { var uploadDatas = HttpHelper.Get<UploadDatas>(string.Format(serviceBaseUri + "/UploadFiles")); mapper = new AutoDataContractMapper(); var files = new UploadFilesModel(); mapper.MapList(uploadDatas, files, typeof(UploadModel)); Model = files; return files; }
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; }