public void CopyPropertiesTest1() { var pi1 = new PhoneItem() { FaxNumber = "456598784532", PhoneNumber = "124565789854" }; var pi2 = new PhoneItem() { FaxNumber = "789874654312", PhoneNumber = "684763251325" }; var phoneItems = new List <PhoneItem>() { pi1, pi2 }; var address = new Address() { Id = 1, City = "Rennes", Street = "rue de la paix" }; var objOrigin = new Employee { Id = 0, Name = "Bernard", Password = "******", Address = address, PhoneItems = phoneItems }; var objDestination = new Customer(); CopyUtils.CopyProperties(objDestination, objOrigin); Assert.IsTrue(objDestination.Id.Equals(objOrigin.Id)); Assert.IsNull(objDestination.GetName()); Assert.IsNull(objDestination.Address); Assert.IsNull(objDestination.Emails); }
// метод для добавления товара в корзину public void AddItem(PhoneItem phone, int quantity) { CartLine line = lineCollection.SingleOrDefault(x => x.Phone_cart.Id == phone.Id); //если товар не найден в корзинеб то он добавляется туда if (line == null) { lineCollection.Add(new CartLine { Phone_cart = phone, Quantity = quantity }); } //если найден то увеличивается количество else { if (quantity > 0) { line.Quantity += quantity; } else { if (quantity < 0 && line.Quantity != 1) { line.Quantity += quantity; } } } }
public ActionResult Add(PhoneItem phoneItem) { PhoneItemManager.AddPhone(phoneItem); var results = PhoneItemManager.GetPhones(); return(View("../Phone/AddResult")); }
private void PhoneForm_Load(object sender, EventArgs e) { IntPtr pIcon = Resources.phone.GetHicon(); Icon = Icon.FromHandle(pIcon); textTimer = new Timer(); textTimer.Interval = 1000; textTimer.Tick += new EventHandler(textTimer_Tick); Task.Run(() => { sRepo = new StudentRepo(ApiEndpoint); tRepo = new TeacherRepo(ApiEndpoint); Students = sRepo.all(); Teachers = tRepo.all(); var sItems = PhoneItem.FromStudentList(Students); var tItems = PhoneItem.FromTeacherList(Teachers); PhoneItems = new List <PhoneItem>(); PhoneItems.AddRange(sItems); PhoneItems.AddRange(tItems); PhoneItems = PhoneItems.OrderBy(pi => pi.Name).ToList(); }); }
public async Task <ActionResult> Edit(PhoneItem phoneItem) { await PhoneItemManager.EditPhoneAsync(phoneItem); //var result = InstrumentManager.GetInstruments(); return(RedirectToAction("../Home/Index")); }
int IComparer.Compare(Object a, Object b) { PhoneItem a1 = a as PhoneItem; PhoneItem b1 = b as PhoneItem; return(string.Compare(a1.Name, b1.Name, false)); }
public async Task <ActionResult> Add(PhoneItem phoneItem) { await PhoneItemManager.AddPhoneAsync(phoneItem); var results = PhoneItemManager.GetPhones(); return(View("../Phone/AddResult")); }
public static void AddPhone(PhoneItem inst) { inst.Id = Guid.NewGuid(); using (DataBaseContext db = new DataBaseContext()) { db.Phones.Add(inst); db.SaveChanges(); } }
public ActionResult RemoveFromCart(Guid id) { PhoneItem phone = PhoneItemManager.Get(id); if (phone != null) { GetCart().RemoveLine(phone); } return(RedirectToAction("Index", "Cart")); }
public RedirectToRouteResult PlusQuantityFromCart(Guid id) { PhoneItem phone = PhoneItemManager.Get(id); if (phone != null) { GetCart().AddItem(phone, 1); } ViewBag.Count = GetCart().Lines.Count(); return(RedirectToAction("Index", "Cart")); }
public static PhoneItem CreatePhoneItem(int ID, byte[] rowVersion, string mDN, string mSID, string mEID, string eSN, string mSL, bool active, int phoneItem_SubscriberItem) { PhoneItem phoneItem = new PhoneItem(); phoneItem.Id = ID; phoneItem.RowVersion = rowVersion; phoneItem.MDN = mDN; phoneItem.MSID = mSID; phoneItem.MEID = mEID; phoneItem.ESN = eSN; phoneItem.MSL = mSL; phoneItem.Active = active; phoneItem.PhoneItem_SubscriberItem = phoneItem_SubscriberItem; return(phoneItem); }
public static void EditPhone(PhoneItem phone) { using (DataBaseContext db = new DataBaseContext()) { var phone2 = db.Phones.SingleOrDefault(x => x.Id == phone.Id); phone2.ModelOfPhone = phone.ModelOfPhone; phone2.Price = phone.Price; phone2.Description = phone.Description; phone2.ImgUrl = phone.ImgUrl; phone2.Category = phone.Category; phone2.SubCategory = phone.SubCategory; db.SaveChanges(); } }
public static void DeletePhone(Guid id) { using (DataBaseContext db = new DataBaseContext()) { var temp = new PhoneItem(); foreach (var item in db.Phones) { if (item.Id == id) { temp = item; } } db.Phones.Remove(temp); db.SaveChanges(); } }
public static async Task <bool> AddPhoneAsync(PhoneItem phoneItem) { if (phoneItem != null) { phoneItem.Id = Guid.NewGuid(); using (DataBaseContext db = new DataBaseContext()) { db.Phones.Add(phoneItem); await db.SaveChangesAsync(); } return(true); } else { return(false); } }
public static async Task <bool> DeletePhoneAsync(Guid id) { using (DataBaseContext db = new DataBaseContext()) { var temp = new PhoneItem(); foreach (var item in db.Phones) { if (item.Id == id) { temp = item; } } db.Phones.Remove(temp); await db.SaveChangesAsync(); return(true); } }
/// <inheritdoc /> public async Task AddPhoneAsync(PhoneItem phoneitem) { using (var context = new PhoneContextApi()) { var place = await context.Places.FirstOrDefaultAsync(p => p.Name == phoneitem.Place); var phone = new Phone() { Name = phoneitem.Name, Post = phoneitem.Post, Department = phoneitem.Department, Description = phoneitem.Description, Nomer = phoneitem.Nomer, PlaceId = place.Id }; context.Phones.Add(phone); await context.SaveChangesAsync(); } }
/*private string phone; // khai báo biến ,biến này đc dùng để set vào kiểu dữ liệu tạo ra (NewItem) * private string name; */ /*public string Phone { get => phone; set => phone = value; } * public string Name { get => name; set => name = value; }*/ public override void insertPhone(string name, string phone) { if (PhoneList != null && UserIsExited(name)) { foreach (PhoneItem phoneItem in PhoneList) { if (phoneItem.Name == name) { if (phoneItem.PhoneNumber != phone) { phoneItem.PhoneNumber += ":" + phone; } } } } else { // cách 1: var phoneItem = new PhoneItem(); phoneItem.Name = name; // đây là setter khai báo kiểu này là khỏi cần khai báo biến (private string phone và get set cho nó). phoneItem.PhoneNumber = phone; PhoneList.Add(phoneItem); } /* * // cách 2: * var pI = new PhoneItem() * { * Name = name, * PhoneNumber = phone * }; * PhoneList.Add(pI); * * // cách 3: * PhoneList.Add(new PhoneItem() * { * Name = name, * PhoneNumber = phone * }); */ }
/// <inheritdoc /> public async Task UpdatePhoneAsync(int id, PhoneItem phoneitem) { using (var context = new PhoneContextApi()) { var place = await context.Places.FirstOrDefaultAsync(p => p.Name == phoneitem.Place); var phone = new Phone() { Id = phoneitem.Id, Name = phoneitem.Name, Post = phoneitem.Post, Department = phoneitem.Department, Description = phoneitem.Description, Nomer = phoneitem.Nomer, PlaceId = place.Id }; context.Entry(phone).State = EntityState.Modified; var phoneInDb = await context.Phones.FirstOrDefaultAsync(p => p.Id == id); await context.SaveChangesAsync(); } }
public override void InsertPhone(string name, string phone) { if (PhoneList != null && UserIsExited(name)) //đôi cái tên vào đây nếu có thì thêm k có thôi { foreach (PhoneItem phoneItem in PhoneList) { if (phoneItem.Name == name) { if (phoneItem.PhoneNumber != phone) { phoneItem.PhoneNumber += ":" + phone; } } } } else { //cach1 var phoneItem = new PhoneItem(); phoneItem.Name = name; phoneItem.PhoneNumber = phone; PhoneList.Add(phoneItem); //cach2 //var pI = new PhoneItem() //giong nhu tren //{ // Name = name, // PhoneNumber = phone //}; //PhoneList.Add(pI); //cach3 //PhoneList.Add(new PhoneItem() //{ // // Name = name, // PhoneNumber = phone //}); } }
public override void InsertPhone(string name, string phone) { if (PhoneLists != null && UserIsExited(name)) { foreach (PhoneItem phoneItem in PhoneLists) { if (phoneItem.Name == name) { if (phoneItem.PhoneNumber != phone) { phoneItem.PhoneNumber += ":" + phone; } } } } else { // cach 1 var phoneItem = new PhoneItem(); phoneItem.Name = name; phoneItem.PhoneNumber = phone; PhoneLists.Add(phoneItem); } // cach 2 //var phone2 = new PhoneItem() //{ // Name = name, // PhoneNumber = phone //}; //PhoneLists.Add(phone2); // Cach 3 //PhoneLists.Add(new PhoneItem() //{ // Name = name, // PhoneNumber = phone //}); }
private void AddPhone(object obj) { if (UsersVM != null) { Base <UserItem> tmp = new Base <UserItem>(); tmp.Q = UsersVM.Q; tmp.R = UsersVM.R; tmp.T = UsersVM.T; tmp.D = new D <UserItem>(); tmp.D.count = UsersVM.D.count; tmp.D.items = new List <UserItem>(); foreach (UserItem item in UsersVM.D.items) { UserItem itmp = new UserItem(); itmp.group = item.group; itmp.login = item.login; itmp.name = item.name; itmp.phones = item.phones; tmp.D.items.Add(itmp); } if (tmp.D.items[(int)obj].phones == null) { tmp.D.items[(int)obj].phones = new List <PhoneItem>(); } int lastId = 0; foreach (PhoneItem phone in tmp.D.items[(int)obj].phones) { if (phone.id > lastId) { lastId = phone.id; } } PhoneItem newPhone = new PhoneItem(); newPhone.id = lastId + 1; tmp.D.items[(int)obj].phones.Add(newPhone); UsersVM = tmp; } }
public override void InsertPhone(string name, string phone) { if (PhoneList != null && UserIsExited(name)) { foreach (PhoneItem phoneItem in PhoneList) { if (phoneItem.Name == name) { if (phoneItem.PhoneNumber != phone) { phoneItem.PhoneNumber += ":" + phone; } } } } else { var phoneItem = new PhoneItem(); phoneItem.Name = name; phoneItem.PhoneNumber = phone; PhoneList.Add(phoneItem); } }
public static async Task <bool> EditPhoneAsync(PhoneItem phoneItem) { using (DataBaseContext db = new DataBaseContext()) { var phoneItem2 = await db.Phones.SingleOrDefaultAsync(x => x.Id == phoneItem.Id); if (phoneItem2 != null) { phoneItem2.ModelOfPhone = phoneItem.ModelOfPhone; phoneItem2.Price = phoneItem.Price; phoneItem2.Description = phoneItem.Description; phoneItem2.ImgUrl = phoneItem.ImgUrl; phoneItem2.Category = phoneItem.Category; phoneItem2.SubCategory = phoneItem.SubCategory; await db.SaveChangesAsync(); return(true); } else { return(false); } } }
//метод для удаления товара из корзины public void RemoveLine(PhoneItem phone) { lineCollection.RemoveAll(l => l.Phone_cart.Id == phone.Id); }
public void AddToPhone(PhoneItem phoneItem) { base.AddObject("Phone", phoneItem); }
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 static PhoneItem CreatePhoneItem(int ID, byte[] rowVersion, string mDN, string mSID, string mEID, string eSN, string mSL, bool active, int phoneItem_SubscriberItem) { PhoneItem phoneItem = new PhoneItem(); phoneItem.Id = ID; phoneItem.RowVersion = rowVersion; phoneItem.MDN = mDN; phoneItem.MSID = mSID; phoneItem.MEID = mEID; phoneItem.ESN = eSN; phoneItem.MSL = mSL; phoneItem.Active = active; phoneItem.PhoneItem_SubscriberItem = phoneItem_SubscriberItem; return phoneItem; }
public ActionResult Edit(PhoneItem phoneItem) { PhoneItemManager.EditPhone(phoneItem); //var result = InstrumentManager.GetInstruments(); return(RedirectToAction("../Home/Index")); }