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 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); }
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 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 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); }