public async Task <Schools> GetData(ISchoolsDataService dataService, int startIndex, int maxIndex) { Schools schoolList = new Schools(); List <SchoolItem> schools; int index = 0; int indexCounter = 0; int schoolCount; ErrorString = ""; try { schools = await dataService.GetSchoolsAsync(); MaxListCount = schools.Count; if (maxIndex == 0) { schoolCount = schools.Count; } else if (maxIndex > schools.Count) { schoolCount = schools.Count; } else { schoolCount = maxIndex; } schoolList.schools = null; if (schools.Count > 0) { schoolList.schools = new SchoolItem[schoolCount]; } foreach (SchoolItem school in schools) { if (((indexCounter++ >= startIndex) && (index < maxIndex)) || (maxIndex == 0)) { SchoolItem newSchool = new SchoolItem { Id = school.Id, name = school.name, street = school.street, city = school.city, state = school.state, zip = school.zip }; schoolList.schools[index++] = newSchool; } } } catch (Exception ex) { ErrorString = $"Exception getting our schools database: { ex.Message }"; } return(schoolList); }
public static List <ShopItem> GetBySchool(SchoolItem School) { if (School == null) { return(new List <ShopItem>()); } return(ShopItemCache.Where(s => s.SchoolItemIds.Contains(School.Id)).ToList()); }
public async Task <SchoolItem> GetSchoolAsync(int id) { using SchoolDBContext context = _contextFactory.CreateDbContext(); SchoolModel entity = await context.SchoolModels .FirstOrDefaultAsync((e) => e.Id == id); SchoolItem school = MakeSchoolFromModel(entity); return(school); }
public ActionResult Post([FromBody] SchoolItem value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var item = _service.Add(value); return(CreatedAtAction("Get", new { id = item.Id }, item)); }
public async Task Create(SchoolItem school) { var p = new { school.name, school.street, school.city, school.state, school.zip }; await _dataAccess.SaveData("dbo.spSchools_Create", p, "SQLDB"); }
internal static SchoolItem MakeSchoolFromModel(SchoolModel schoolModel) { SchoolItem school = new SchoolItem { Id = schoolModel.Id, name = schoolModel.Name, street = schoolModel.Street, city = schoolModel.City, state = schoolModel.State, zip = schoolModel.Zip }; return(school); }
public void Add_ValidObjectPassed_ReturnsCreatedResponse() { // Arrange SchoolItem testItem = new SchoolItem() { Name = "Rahul", Principal = "Balakumar", Fees = 7.00M }; // Act var createdResponse = _controller.Post(testItem); // Assert Assert.IsType <CreatedAtActionResult>(createdResponse); }
public async Task Create(SchoolItem school) { SchoolModel schoolModel = new SchoolModel(); if (school.name == null) { schoolModel.Name = ""; } else { schoolModel.Name = school.name; } if (school.street == null) { schoolModel.Street = ""; } else { schoolModel.Street = school.street; } if (school.city == null) { schoolModel.City = ""; } else { schoolModel.City = school.city; } if (school.state == null) { schoolModel.State = ""; } else { schoolModel.State = school.state; } if (school.zip == null) { schoolModel.Zip = ""; } else { schoolModel.Zip = school.zip; } await _nonQueryDataService.Create(schoolModel); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { _Argument = LeftHand.Gadget.Encoder.DictionaryDecoder(Server.UrlDecode(Request.QueryString.ToString())); } switch (_Argument["Mode"]) { case "Add": _SchoolItem = new SchoolItem(_Argument["AreaItemId"], ""); break; case "Edit": _SchoolItem = SchoolItemManager.Get(_Argument["Id"]); break; } }
public void Add_InvalidObjectPassed_ReturnsBadRequest() { // Arrange var nameMissingItem = new SchoolItem() { Name = "Eshwar", Principal = "Ramesh", Fees = 6.00M }; _controller.ModelState.AddModelError("Name", "Required"); // Act var badResponse = _controller.Post(nameMissingItem); // Assert Assert.IsType <BadRequestObjectResult>(badResponse); }
public void Add_ValidObjectPassed_ReturnedResponseHasCreatedItem() { // Arrange var testItem = new SchoolItem() { Name = "Rahul", Principal = "Balakumar", Fees = 7.00M }; // Act var createdResponse = _controller.Post(testItem) as CreatedAtActionResult; var item = createdResponse.Value as SchoolItem; // Assert Assert.IsType <SchoolItem>(item); Assert.Equal("Rahul", item.Name); }
public async Task <List <SchoolItem> > GetSchoolsAsync() { List <SchoolItem> schools = new List <SchoolItem>(); using (SchoolDBContext context = _contextFactory.CreateDbContext()) { IEnumerable <SchoolModel> entities = await context.SchoolModels .ToListAsync(); foreach (SchoolModel schoolModel in entities) { SchoolItem school = MakeSchoolFromModel(schoolModel); schools.Add(school); } } return(schools.ToList <SchoolItem>()); }
protected void vSchoolList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SchoolItem SchoolItem = (SchoolItem)e.Item.DataItem; //vName Literal vName = (Literal)e.Item.FindControl("vName"); vName.Text = SchoolItem.Name; //Sort Literal vSort = (Literal)e.Item.FindControl("vSort"); vSort.Text = SchoolItem.Sort.ToString(); //Edit HyperLink vEdit = (HyperLink)e.Item.FindControl("vEdit"); Dictionary <string, string> Argument = new Dictionary <string, string>(); Argument.Add("Mode", "Edit"); Argument.Add("Id", SchoolItem.Id); vEdit.NavigateUrl = "/School/Manager/School_Modify.aspx?" + Server.UrlEncode(LeftHand.Gadget.Encoder.DictionaryEncoder(Argument)); } }
public OrderItem(ShopItem Shop, AreaItem AreaItem, SchoolItem SchoolItem, DateTime?OrderDate, string OrderRound) { this.Id = -1; this.MemberAccount = ""; this.MemberName = ""; this.MemberPhone = ""; if (Shop != null) { this.ShopId = Shop.Id; this.ShopName = Shop.Name; this.ShopPhone = Shop.Phone; this.ShopAddress = Shop.Address; this.Shoplatitude = Shop.Latitude; this.Shoplongitude = Shop.Longitude; } if (AreaItem != null) { this.MemberArea = AreaItem.Name; } if (SchoolItem != null) { this.MemberSchool = SchoolItem.Name; } this.OrderDate = OrderDate; this.OrderRound = OrderRound; this.State = StateType.新預約; this.QuestionResult = ""; this.SyatemRemark = ""; this.UpdateTime = DateTime.Now; this.CreateTime = DateTime.Now; }
public async Task Create(SchoolItem school) { _schools.Add(school); await Task.Delay(0); }
private void CreateData() { if (this._userData == null) { return; } User user = this._userData.user; if (!string.IsNullOrEmpty(this._userData.Activity) || this._userData.AdminLevel > 1) { this.InfoSections.Add(new ProfileInfoSectionItem() { Items = new List <ProfileInfoItem>() { (ProfileInfoItem) new StatusItem((IProfileData)this._userData) } }); } List <ProfileInfoItem> profileInfoItemList1 = new List <ProfileInfoItem>(); if (!string.IsNullOrEmpty(user.bdate)) { profileInfoItemList1.Add((ProfileInfoItem) new BirthdayItem(this._userData)); } if (!string.IsNullOrEmpty(user.home_town)) { profileInfoItemList1.Add((ProfileInfoItem) new HomeTownItem(user.home_town)); } Occupation occupation = user.occupation; if (occupation != null) { string str = occupation.name; if (occupation.type == OccupationType.university && user.universities != null) { University university = user.universities.FirstOrDefault <University>((Func <University, bool>)(u => u.id == occupation.id)); if (university != null && university.graduation > 0) { str = string.Format("{0} '{1:00}", (object)university.name, (object)(university.graduation % 100)); } } else if (occupation.type == OccupationType.school && user.schools != null) { foreach (School school in user.schools) { long result; if (long.TryParse(school.id, out result) && result == occupation.id && school.year_graduated > 0) { str = string.Format("{0} '{1:00}", (object)school.name, (object)(school.year_graduated % 100)); } } } occupation.name = str; profileInfoItemList1.Add((ProfileInfoItem)OccupationItem.GetOccupationItem(occupation, this._userData.occupationGroup)); } if (this._userData.user.relation != 0) { profileInfoItemList1.Add((ProfileInfoItem) new RelationshipItem(this._userData)); } if (user.personal != null && !user.personal.langs.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new LanguagesItem(this._userData)); } if (user.relatives != null && user.relatives.Count > 0) { List <Relative> relatives1 = user.relatives; List <User> relatives2 = this._userData.relatives; List <Relative> list1 = relatives1.Where <Relative>((Func <Relative, bool>)(r => r.type == RelativeType.grandparent)).ToList <Relative>(); if (!list1.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new GrandparentsItem((IEnumerable <Relative>)list1, relatives2)); } List <Relative> list2 = relatives1.Where <Relative>((Func <Relative, bool>)(r => r.type == RelativeType.parent)).ToList <Relative>(); if (!list2.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new ParentsItem((IEnumerable <Relative>)list2, relatives2)); } List <Relative> list3 = relatives1.Where <Relative>((Func <Relative, bool>)(r => r.type == RelativeType.sibling)).ToList <Relative>(); if (!list3.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new SiblingsItem((IEnumerable <Relative>)list3, relatives2)); } List <Relative> list4 = relatives1.Where <Relative>((Func <Relative, bool>)(r => r.type == RelativeType.child)).ToList <Relative>(); if (!list4.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new ChildrenItem((IEnumerable <Relative>)list4, relatives2)); } List <Relative> list5 = relatives1.Where <Relative>((Func <Relative, bool>)(r => r.type == RelativeType.grandchild)).ToList <Relative>(); if (!list5.IsNullOrEmpty()) { profileInfoItemList1.Add((ProfileInfoItem) new GrandchildrenItem((IEnumerable <Relative>)list5, relatives2)); } } if (profileInfoItemList1.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem() { Items = profileInfoItemList1 }); } List <ProfileInfoItem> profileInfoItemList2 = new List <ProfileInfoItem>(); profileInfoItemList2.AddRange((IEnumerable <ProfileInfoItem>)PhoneItem.GetPhones(this._userData)); if (this._userData.city != null) { profileInfoItemList2.Add((ProfileInfoItem) new CityItem(this._userData.city.name)); } profileInfoItemList2.Add((ProfileInfoItem) new VKSocialNetworkItem((IProfileData)this._userData)); if (!string.IsNullOrEmpty(user.skype)) { profileInfoItemList2.Add((ProfileInfoItem) new SkypeSocialNetworkItem(user.skype)); } if (!string.IsNullOrEmpty(user.facebook)) { profileInfoItemList2.Add((ProfileInfoItem) new FacebookSocialNetworkItem(user.facebook, user.facebook_name)); } if (!string.IsNullOrEmpty(user.twitter)) { profileInfoItemList2.Add((ProfileInfoItem) new TwitterSocialNetworkItem(user.twitter)); } if (!string.IsNullOrEmpty(user.instagram)) { profileInfoItemList2.Add((ProfileInfoItem) new InstagramSocialNetworkItem(user.instagram)); } if (!string.IsNullOrEmpty(user.site)) { profileInfoItemList2.Add((ProfileInfoItem) new SiteItem(user.site)); } if (profileInfoItemList2.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_ContactInformation) { Items = profileInfoItemList2 }); } List <ProfileInfoItem> profileInfoItemList3 = new List <ProfileInfoItem>(); profileInfoItemList3.AddRange((IEnumerable <ProfileInfoItem>)UniversityItem.GetUniversities(user.universities, this._userData.universityGroups)); profileInfoItemList3.AddRange((IEnumerable <ProfileInfoItem>)SchoolItem.GetSchools(user.schools, this._userData.schoolGroups)); if (profileInfoItemList3.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Education.ToUpperInvariant()) { Items = profileInfoItemList3 }); } List <ProfileInfoItem> profileInfoItemList4 = new List <ProfileInfoItem>(); UserPersonal personal = user.personal; if (personal != null) { if (personal.political > 0 && personal.political <= 9) { profileInfoItemList4.Add((ProfileInfoItem) new PoliticalViewsItem(personal.political)); } if (!string.IsNullOrEmpty(personal.religion)) { profileInfoItemList4.Add((ProfileInfoItem) new WorldViewItem(personal.religion)); } if (personal.life_main > 0 && personal.life_main <= 8) { profileInfoItemList4.Add((ProfileInfoItem) new PersonalPriorityItem(personal.life_main)); } if (personal.people_main > 0 && personal.people_main <= 6) { profileInfoItemList4.Add((ProfileInfoItem) new ImportantInOthersItem(personal.people_main)); } if (personal.smoking > 0 && personal.smoking <= 5) { profileInfoItemList4.Add((ProfileInfoItem) new BadHabitsItem(CommonResources.ProfilePage_Info_ViewsOnSmoking, personal.smoking)); } if (personal.alcohol > 0 && personal.alcohol <= 5) { profileInfoItemList4.Add((ProfileInfoItem) new BadHabitsItem(CommonResources.ProfilePage_Info_ViewsOnAlcohol, personal.alcohol)); } if (!string.IsNullOrEmpty(personal.inspired_by)) { profileInfoItemList4.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_InspiredBy, personal.inspired_by, null, ProfileInfoItemType.RichText)); } } if (profileInfoItemList4.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Beliefs) { Items = profileInfoItemList4 }); } List <ProfileInfoItem> profileInfoItemList5 = new List <ProfileInfoItem>(); if (!string.IsNullOrEmpty(user.activities)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Activities, user.activities, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.interests)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Interests, user.interests, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.music)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Music, user.music, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.movies)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Movies, user.movies, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.tv)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_TV, user.tv, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.books)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Books, user.books, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.games)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Games, user.games, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.quotes)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_Quotes, user.quotes, null, ProfileInfoItemType.RichText)); } if (!string.IsNullOrEmpty(user.about)) { profileInfoItemList5.Add((ProfileInfoItem) new CustomItem(CommonResources.ProfilePage_Info_About, user.about, null, ProfileInfoItemType.RichText)); } if (profileInfoItemList5.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_PersonalInfomation) { Items = profileInfoItemList5 }); } List <ProfileInfoItem> profileInfoItemList6 = new List <ProfileInfoItem>(); if (!user.military.IsNullOrEmpty()) { profileInfoItemList6.AddRange((IEnumerable <ProfileInfoItem>)MilitaryItem.GetMilitaryItems(user.military, this._userData.militaryCountries)); if (profileInfoItemList6.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_MilitaryService) { Items = profileInfoItemList6 }); } } List <ProfileInfoItem> profileInfoItemList7 = new List <ProfileInfoItem>(); CareerData careerData = this._userData.careerData; if (careerData != null && !careerData.Items.IsNullOrEmpty()) { profileInfoItemList7.AddRange((IEnumerable <ProfileInfoItem>)CareerItem.GetCareerItems(careerData.Items, careerData.Cities, careerData.Groups)); if (profileInfoItemList7.Count > 0) { this.InfoSections.Add(new ProfileInfoSectionItem(CommonResources.ProfilePage_Info_Career) { Items = profileInfoItemList7 }); } } if (this.InfoSections.Count <= 0) { return; } this.InfoSections.Last <ProfileInfoSectionItem>().DividerVisibility = Visibility.Collapsed; }
public SchoolItem Add(SchoolItem newItem) { throw new NotImplementedException(); }
public SchoolItem Add(SchoolItem newItem) { newItem.Id = Guid.NewGuid(); _schoolCart.Add(newItem); return(newItem); }