public int Save(Comments data) { int result = 0; if (data != null && data.ID > 0) { using (var srv = new Datav3DBContext()) { var oldData = srv.Comments.FirstOrDefault(f => f.ID == data.ID); oldData.IsActive = data.IsActive; oldData.UDate = DateTime.Now; oldData.UMainPartyID = data.UMainPartyID; result = srv.SaveChanges() > 0 ? data.ID : 0; } } else { using (var srv = new Datav3DBContext()) { srv.Comments.Add(data); result = srv.SaveChanges() > 0 ? data.ID : 0; } } return(result); }
public int SaveRelProperty(int CampID, int ValueID) { int result = 0; using (var srv = new Datav3DBContext()) { var data = srv.RelPropertyValueCamping.FirstOrDefault(f => f.CampingID == CampID && f.PropertyValueID == ValueID); if (data != null) { data.IsDelete = data.IsDelete ? false : true; } else { RelPropertyValueCamping newRel = new RelPropertyValueCamping(); newRel.CampingID = CampID; newRel.PropertyValueID = ValueID; newRel.CreatedDate = DateTime.Now; newRel.CreatedID = 1; newRel.IsDelete = false; srv.RelPropertyValueCamping.Add(newRel); } result = srv.SaveChanges(); } return(result); }
public List <Comments> Search(int _campingID = 0, int _mainPartyID = 0, bool IsActive = true) { List <Comments> result = new List <Comments>(); using (var srv = new Datav3DBContext()) { IQueryable <Comments> data = srv.Comments; if (_campingID > 0) { data = data.Where(w => w.CampingID == _campingID); } if (_mainPartyID > 0) { data = data.Where(w => w.MainPartyID == _mainPartyID); } if (IsActive) { data = data.Where(w => w.IsActive == IsActive); } result = data.ToList(); } return(result); }
public int Add(Property model) { int result = 0; if (model.ID > 0) { model.UpdateDate = DateTime.Now; model.DefaultName = model.Name; model.CreatedDate = DateTime.Now; using (var srv = new Datav3DBContext ()) { //srv.Property.Attach(model); srv.Entry(model).State = System.Data.Entity.EntityState.Modified; srv.SaveChanges(); } } else { using (var srv = new Datav3DBContext()) { model.IsDelete = false; model.IsActive = false; srv.Property.Add(model); result = srv.SaveChanges(); } } return(result); }
public List <PropertyType> SearchForDropDow() { List <PropertyType> result = new List <PropertyType>(); using (var srv = new Datav3DBContext()) result = srv.PropertyType.Where(w => w.IsDelete == false).ToList(); return(result); }
private void UpdateLastLoginDate(int ID) { using (var srv = new Datav3DBContext()) { var data = srv.MainParty.FirstOrDefault(f => f.ID == ID); data.LastLoginDate = DateTime.Now; srv.Entry(data).State = System.Data.Entity.EntityState.Modified; srv.SaveChanges(); } }
public File GetByID(int ID) { File result = new File(); using (var srv = new Datav3DBContext()) { result = srv.File.FirstOrDefault(f => f.ID == ID); } return(result); }
public List <ContactType> Search() { List <ContactType> result = new List <ContactType>(); using (var srv = new Datav3DBContext()) { result = srv.ContactType.Where(w => w.IsActive == true).ToList(); } return(result); }
public List <Country> Search() { List <Country> result = new List <Country>(); using (var srv = new Datav3DBContext()) { result = srv.Country.Where(w => w.IsDelete == false).ToList(); } return(result); }
public Property GetByID(int ID) { Property result = new Property(); using (var srv = new Datav3DBContext()) { result = srv.Property.Include("PropertyValue").Include("PropertyType").FirstOrDefault(w => w.IsDelete == false && w.ID == ID); } return(result); }
public bool IsCheck(int CampID, int ValueID) { bool result = false; using (var srv = new Datav3DBContext()) { var data = srv.RelPropertyValueCamping.FirstOrDefault(f => f.CampingID == CampID && f.PropertyValueID == ValueID && f.IsDelete == false); result = data != null && data.ID > 0 ? true : false; } return(result); }
public List <Camping> Search() { List <Camping> result = new List <Camping>(); using (var srv = new Datav3DBContext()) { var data = srv.Camping.Where(w => w.ID > 0); result = data.ToList(); } return(result); }
public List <City> Search(int CountryID) { List <City> result = new List <City>(); using (var srv = new Datav3DBContext()) { result = srv.City.Where(w => w.IsDelete == false && w.CountryID == CountryID) .OrderBy(o => o.Name) .ToList(); } return(result); }
public List <PropertyValue> Search(int?PropertyID) { List <PropertyValue> result = new List <PropertyValue>(); using (var srv = new Datav3DBContext()) { var data = srv.PropertyValue.Include("Property").Include("Property.PropertyType").Where(w => w.IsDelete == false && w.IsActive == true); if (PropertyID != null && PropertyID > 0) { data = data.Where(w => w.PropertyID == PropertyID); } result = data.ToList(); } return(result); }
public List <File> Search(int CampID = 0) { List <File> result = new List <File>(); using (var srv = new Datav3DBContext()) { IQueryable <File> data = srv.File; if (CampID > 0) { data = data.Where(w => w.CampID == CampID); } result = data.ToList(); } return(result); }
public int Save(Camping data) { int result = 0; #region UPDATE if (data.ID > 0) { try { using (var srv = new Datav3DBContext()) { var oldData = srv.Camping.FirstOrDefault(f => f.ID == data.ID); oldData.Name = data.Name; oldData.Latitude = data.Latitude; oldData.Longitude = data.Longitude; oldData.Description = data.Description; oldData.AuthorizedPersonel = data.AuthorizedPersonel; result = srv.SaveChanges() > 0 ? data.ID : 0; } } catch (Exception) { throw; } } #endregion #region INSERT else { try { using (var srv = new Datav3DBContext()) { data.IDate = DateTime.Now; data.IMainPartyID = 1; srv.Camping.Add(data); result = srv.SaveChanges() > 0 ? data.ID : 0; } } catch (Exception ex) { throw; } } #endregion return(result); }
public int Save(File data) { int result = 0; if (data != null && (data.ID <= 0 || data.ID == null)) { using (var srv = new Datav3DBContext()) { data.IDate = DateTime.Now; data.IUser = 1; data.TypeID = 1; srv.File.Add(data); result = srv.SaveChanges(); } } return(result); }
public int Save(Contact data) { int result = 0; if (data != null && data.ID > 0) { } else { using (var srv = new Datav3DBContext()) { data.IDate = DateTime.Now; data.IMainPartyID = 1; srv.Contact.Add(data); srv.SaveChanges(); result = data.ID; } } return(result); }
public List <Property> Search(byte?TypeID, bool forWeb = false) { List <Property> result = new List <Property>(); using (var srv = new Datav3DBContext()) { var data = srv.Property.Include("PropertyValue").Include("PropertyType").Where(w => w.IsDelete == false); if (TypeID != null && TypeID > 0) { data = data.Where(w => w.TypeID == TypeID); } if (forWeb) { var _dataValue = srv.PropertyValue.Where(w => w.IsDelete == false && w.IsActive == true); data = data.Where(w => _dataValue.Select(s => s.PropertyID).Contains(w.ID)); } result = data.ToList(); } return(result); }
public int Add(PropertyValue data) { int result = 0; if (data.ID > 0) { } else { using (var srv = new Datav3DBContext()) { data.CreatedDate = DateTime.Now; data.DefaultName = data.Name; data.IsDelete = false; data.IsActive = true; srv.PropertyValue.Add(data); result = srv.SaveChanges(); } } return(result); }
public List <Menu> Search(int ParentID = 0) { List <Menu> result = new List <Menu>(); using (var srv = new Datav3DBContext()) { var data = srv.Menu.Where(w => w.IsDelete == false); if (ParentID > 0) { data = data.Where(w => w.ParentID == ParentID); } else { data = data.Where(w => w.ParentID == null || w.ParentID == 0); } result = data.ToList(); //tolist diyene kadar henüz db den verileri getirmemişti. Db için sorguyu hazırladı to list dediğinda dataları db den getirir // } return(result); }
public int SignIn(string Email, string Password, bool IsRemember) { int result = 0; if (Email != null && Email.Length > 0 && Password != null && Password.Length > 0) { using (var srv = new Datav3DBContext()) { var data = srv.MainParty.Include("MainPartyType").FirstOrDefault(f => f.IsDelete == false && f.IsActive == true && f.Email == Email && f.Password == Password ); if (data != null && data.ID > 0) { result = data.ID; HttpContext.Current.Session["CurrentUser"] = data; UpdateLastLoginDate(data.ID); } } } return(result); }
public Camping GetByID(int ID) { Camping result = new Camping(); if (ID > 0) { using (var srv = new Datav3DBContext()) { //yourObjectContext.ContextOptions.LazyLoadingEnabled = false; srv.Configuration.LazyLoadingEnabled = false; result = srv.Camping .Include("RelPropertyValueCamping") .Include("Comments") //.Include("Comments.MainParty") .Include("Contact") //.Include("Contact.ContactType") .Include("File") .FirstOrDefault(w => w.ID == ID); result.File = result.File.Where(w => w.TypeID == 1).ToList(); } } //var asd = GetByIDForMaps(ID); return(result); }
public string GetByIDForMaps(int ID) { string result = ""; if (ID > 0) { using (var srv = new Datav3DBContext()) { //yourObjectContext.ContextOptions.LazyLoadingEnabled = false; srv.Configuration.LazyLoadingEnabled = false; var data = srv.Camping .Include("RelPropertyValueCamping") .Include("Comments") .Include("Contact") .FirstOrDefault(w => w.ID == ID); result = JsonConvert.SerializeObject(data, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize }); } } //JsonSerializer serializer = new JsonSerializer(); return(result); }