public bool UpdateSurveyLocation(FishSurveyLocation item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Fish_SurveyLocation efItem = context.Fish_SurveyLocation.Where(b => b.SurveyID == item.SurveyID && b.SurveyNumber == item.SurveyNumber).FirstOrDefault(); if (efItem == null) { return(result); } efItem.GeneratorID = item.GeneratorID; efItem.LocationDetails = item.LocationDetails; efItem.SurveyDate = item.SurveyDate; efItem.SurveyDurationSeconds = item.SurveyDurationSeconds; efItem.SurveyLocationComments = item.SurveyLocationComments; efItem.SurveyLocationActive = item.SurveyLocationActive; if (context.SaveChanges() > 0) { result = true; } } } catch (Exception) { } return(result); }
public bool InactivateSurveyLocation(FishSurveyLocation item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Fish_SurveyLocation efItem = context.Fish_SurveyLocation.Where(b => b.SurveyID == item.SurveyID && b.SurveyNumber == item.SurveyNumber).FirstOrDefault(); if (efItem == null) { return(result); } efItem.SurveyLocationActive = false; if (context.SaveChanges() > 0) { result = true; } } } catch (Exception) { } return(result); }
public int CreateSurveyLocation(FishSurveyLocation item) { byte newid = 0; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { var lastItem = context.Fish_SurveyLocation.Where(s => s.SurveyID == item.SurveyID).OrderByDescending(u => u.SurveyNumber).FirstOrDefault(); if (lastItem != null) { newid = lastItem.SurveyNumber; newid++; } Fish_SurveyLocation efItem = new Fish_SurveyLocation() { GeneratorID = item.GeneratorID, LocationDetails = item.LocationDetails, SurveyDate = item.SurveyDate, SurveyDurationSeconds = item.SurveyDurationSeconds, SurveyLocationComments = item.SurveyLocationComments, SurveyNumber = newid, SurveyID = item.SurveyID }; context.Fish_SurveyLocation.Add(efItem); if (context.SaveChanges() > 0) { return(newid); } } } catch (Exception e) { throw e; } return(newid); }