public bool UpdateSurvey(FishSurvey item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Fish_Survey efItem = context.Fish_Survey.Where(b => b.SurveyID == item.SurveyID).FirstOrDefault(); if (efItem == null) { return(result); } efItem.SamplePointAreaID = item.SamplePointAreaID; efItem.SourceID = LIMS_SOURCEID; efItem.SurveyYear = item.SurveyYear; efItem.SurveyComments = item.SurveyComments; efItem.SurveyActive = item.SurveyActive; if (context.SaveChanges() > 0) { result = true; } } } catch (Exception) { } return(result); }
public int CreateSurvey(FishSurvey item) { int newid = 0; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { newid = context.Fish_Survey.OrderByDescending(u => u.SurveyID).FirstOrDefault().SurveyID; newid++; Fish_Survey efItem = new Fish_Survey() { SurveyID = newid, SamplePointAreaID = item.SamplePointAreaID, SourceID = LIMS_SOURCEID, SurveyComments = item.SurveyComments, SurveyYear = item.SurveyYear }; context.Fish_Survey.Add(efItem); if (context.SaveChanges() > 0) { return(newid); } } } catch (Exception e) { throw e; } return(newid); }
public bool InactivateSurvey(FishSurvey item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Fish_Survey efItem = context.Fish_Survey.Where(b => b.SurveyID == item.SurveyID).FirstOrDefault(); if (efItem == null) { return(result); } efItem.SurveyActive = false; if (context.SaveChanges() > 0) { result = true; } } } catch (Exception) { } return(result); }