public static bool SubmitChanges(Branch item) { if (item != null) { dataContext = new RavenPXDataContext(); if (item.ID != Guid.Empty) { Branch oldBranch = GetBranch(item.ID, dataContext); if (oldBranch != null) { oldBranch.LocationName = item.LocationName; oldBranch.Address = item.Address; oldBranch.PhoneNumber = item.PhoneNumber; oldBranch.ZipCode = item.ZipCode; dataContext.SubmitChanges(); if (GetBranch(oldBranch) != null) { return(true); } } else { //should not happen } } else { Branch newBranch = new Branch(); newBranch.ID = Guid.NewGuid(); newBranch.LocationName = item.LocationName; newBranch.Address = item.Address; newBranch.PhoneNumber = item.PhoneNumber; newBranch.ZipCode = item.ZipCode; dataContext.Branches.InsertOnSubmit(newBranch); dataContext.SubmitChanges(); if (GetBranch(newBranch) != null) { return(true); } } } return(false); }
public static bool Delete(Guid ID) { dataContext = new RavenPXDataContext(); Branch item = GetBranch(ID, dataContext); if (item != null) { dataContext.Branches.DeleteOnSubmit(item); dataContext.SubmitChanges(); if (GetBranch(ID, dataContext) == null) { return(true); } } return(false); }
public static bool SubmitChanges(List <XSetting> items) { if (items.Count > 0) { dataContext = new RavenPXDataContext(); List <XSetting> insertList = new List <XSetting>(); foreach (XSetting item in items) { XSetting refItem = GetSetting((int)item.AppKey, dataContext); if (refItem != null) { refItem.Value = item.Value; } else //create entry { refItem = new XSetting { ID = Guid.NewGuid(), ModuleID = item.ModuleID, AppKey = item.AppKey, Value = item.Value }; insertList.Add(refItem); } } dataContext.XSettings.InsertAllOnSubmit(insertList); dataContext.SubmitChanges(); //place a validation here return(true); } //nothing to save return(false); }