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 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 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); }
public string DeleteSurvey(FishSurvey item) { string msg = string.Empty; try { if (ModelState.IsValid) { _fishSvc.InactivateSurvey(item); msg = "Survey inactivated succesfully"; } else { msg = "Data validation not successfull"; } } catch (Exception e) { msg = "Delete Survey. An error has ocurred"; } return(msg); }
public string CreateSurvey([Bind(Exclude = "SurveyID")] FishSurvey item) { string msg = string.Empty; try { if (ModelState.IsValid) { _fishSvc.CreateSurvey(item); msg = "Survey created succesfully"; } else { msg = "Data validation not successfull"; } } catch (Exception e) { msg = "Create Survey. An error has ocurred"; } return(msg); }
public bool CreateSurvey(FishSurvey item) { return(_fishRepo.CreateSurvey(item) > 0); }
public bool UpdateSurvey(FishSurvey item) { return(_fishRepo.UpdateSurvey(item)); }
public bool InactivateSurvey(FishSurvey item) { return(_fishRepo.InactivateSurvey(item)); }