public void GetSaveCoords(int id, string lat, string lng) { double pLat = 0; double pLng = 0; string strLat = StringHelper.FixDecimalSeparator(lat); string strLng = StringHelper.FixDecimalSeparator(lng); if (!double.TryParse(strLat, out pLat)) { return; } if (!double.TryParse(strLng, out pLng)) { return; } using (var context = new BusProjectEntities()) { var st = context.tblStudents.FirstOrDefault(z => z.pk == id); if (st != null) { st.Lat = pLat; st.Lng = pLng; try { context.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } } } }
public List <StudentShortInfo> GetStudentsForMap() { var res = new List <StudentShortInfo>(); using (var context = new BusProjectEntities()) { res = context.tblStudents.Select(data => new StudentShortInfo { Id = data.pk, StudentId = data.studentId, Lat = data.Lat, Lng = data.Lng, Color = string.IsNullOrEmpty(data.Color.Trim()) ? "FF0000" : data.Color.Trim().Replace("#", ""), Name = data.lastName + ", " + data.firstName, CellPhone = data.CellPhone, Email = data.Email, Address = (data.city ?? "") + ", " + (data.street ?? "") + ", " + data.houseNumber, Shicva = data.Shicva, Class = data.@class, Active = data.Active ?? false, SchoolName = data.schoolName }).ToList(); } return(res); }
public static void SetSettingValue(string ns, string key, string value) { using (var context = new BusProjectEntities()) { var entity = context.tblSystems.FirstOrDefault( z => z.strNamespace.ToLower() == ns.ToLower() && z.strKey.ToLower() == key.ToLower()); if (entity != null) { entity.strValue = value; entity.LastModify = DateTime.UtcNow; if (AccountManager.LoginInfo != null) { entity.ModifedBy = AccountManager.LoginInfo.UserId; } } else { entity = new tblSystem() { strNamespace = ns, strKey = key, strValue = value, LastModify = DateTime.UtcNow }; if (AccountManager.LoginInfo != null) { entity.ModifedBy = AccountManager.LoginInfo.UserId; } context.tblSystems.Add(entity); } context.SaveChanges(); } }
public static void create(tblAlertsQueue c) { try { BusProjectEntities db = new BusProjectEntities(); c.id = 9999; db.SaveChanges(); } catch { } }
public static string GetSettingValue(string ns, string key) { string res = null; using (var context = new BusProjectEntities()) { var entity = context.tblSystems.FirstOrDefault( z => z.strNamespace.ToLower() == ns.ToLower() && z.strKey.ToLower() == key.ToLower()); if (entity != null) { res = entity.strValue; } } return(res); }
public object GetFamily(int id) { tblFamily res = null; using (var context = new BusProjectEntities()) { var st = context.tblStudents.FirstOrDefault(z => z.pk == id); if (st != null) { res = context.tblFamilies.FirstOrDefault(z => z.familyId == st.familyId); } } return(new StudentFamilyInfo { Id = id, Family = (res != null ? new FamilyModel(res) : new FamilyModel()) }); }