public bool EditAtm(Atm newAtm) { Atm singleAtm = (from atmdb in dbLink.Atm where atmdb.id == newAtm.id select atmdb).FirstOrDefault(); try { singleAtm.title = newAtm.title; singleAtm.phone = newAtm.phone; singleAtm.addressatm = newAtm.addressatm; singleAtm.gpsX = newAtm.gpsX; singleAtm.gpsY = newAtm.gpsY; singleAtm.dateregister = newAtm.dateregister; singleAtm.mainoffice = newAtm.mainoffice; singleAtm.timeopen = newAtm.timeopen; singleAtm.timeclose = newAtm.timeclose; singleAtm.cashier = newAtm.cashier; singleAtm.description = newAtm.description; singleAtm.idbank = newAtm.idbank; singleAtm.Service = newAtm.Service; dbLink.SaveChanges(); } catch (Exception ex) { string str = ex.Message; return(false); } return(true); }
public bool AddAtm(Atm newAtm) { try { dbLink.Atm.Add(newAtm); dbLink.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public List <Atm> GetAtmFilters(Atm newAtm, bool mainOffice) { List <Atm> search = new List <Atm>();; // здесь будут хранится результаты поиска // берем все atm List <Atm> atm = (from atmdb in dbLink.Atm select atmdb).ToList(); if (newAtm.Bank != null) // банки { search = (from atmdb in atm where atmdb.idbank == newAtm.Bank.id select atmdb).ToList(); atm = search; } if (newAtm.Service.Count > 0) { search = new List <Atm>(); bool result = false; foreach (Atm itemAtm in atm) // прогоняем Atm { foreach (Service item in newAtm.Service) // берем все услуги по фильтру они все должны быть в atm { result = false; foreach (Service itemService in itemAtm.Service) { if (itemService.id == item.id) { result = true; break; } } if (!result) // дальше искать нет смысла { break; } } if (result) { search.Add(itemAtm); } } atm = search; } if (newAtm.timeopen > 0 && newAtm.timeclose > 0) // время работы { search = new List <Atm>(); search = (from atmdb in atm where atmdb.timeopen >= newAtm.timeopen && atmdb.timeclose >= newAtm.timeclose select atmdb).ToList(); atm = search; } if (mainOffice) // главные оффисы { search = new List <Atm>(); search = (from atmdb in atm where atmdb.mainoffice == newAtm.mainoffice select atmdb).ToList(); atm = search; } return(atm); }