public Boolean InsertUpdateCSDirection(CSDirection direction) { InitDB(); //Screen newScreen = new Screen(); CSDirection newDirection = new CSDirection(); try { newDirection.Query.Where( newDirection.Query.Directionalscreenname.IsNotNull() && newDirection.Query.Meetingroomname.IsNotNull() && newDirection.Query.Directionalscreenname.ToLower().Equal(direction.Directionalscreenname.ToLower()) && newDirection.Query.Meetingroomname.ToLower().Equal(direction.Meetingroomname.ToLower())); } catch (Exception) { } Boolean functionResult = false; try { if (newDirection.Query.Load()) //Do update { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Updating Directional Information"); try { newDirection.Directionimageblob = direction.Directionimageblob; } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+ex.Message); newDirection.Directionimageblob = null; } newDirection.Directionimagefile = direction.Directionimagefile; newDirection.Directiontext = direction.Directiontext; newDirection.Save(); functionResult = true; Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Updating Directional Information OK"); } else //Do update { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Inserting New Directional Information"); newDirection = new CSDirection(); try { newDirection.Directionimageblob = direction.Directionimageblob; } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+ex.Message); newDirection.Directionimageblob = null; } newDirection.Directionimagefile = direction.Directionimagefile; newDirection.Directiontext = direction.Directiontext; newDirection.Meetingroomname = direction.Meetingroomname; newDirection.Directionalscreenname = direction.Directionalscreenname; newDirection.Save(); functionResult = true; Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Inserting New Directional Information OK"); } } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Error during Directional Information insert/update:"); Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Message: "+ex.Message); functionResult = false; } return functionResult; }
public Boolean RemoveCSDirection(CSDirection direction) { InitDB(); try { direction.MarkAsDeleted(); direction.Save(); Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Direction deleted ok"); } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Error deleting direction"); return false; } return true; }