public bool InactivateSurvey(BirdSurvey item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Bird_Survey efItem = context.Bird_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 bool UpdateSurvey(BirdSurvey item) { bool result = false; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { Bird_Survey efItem = context.Bird_Survey.Where(b => b.SurveyID == item.SurveyID).FirstOrDefault(); if (efItem == null) { return(result); } efItem.ClimateID = item.ClimateID; efItem.SamplePointAreaID = item.SamplePointAreaID; efItem.SourceID = LIMS_SOURCEID; efItem.SurveyDate = item.SurveyDate; efItem.SurveyorID = item.SurveyorID; efItem.SurveyActive = item.SurveyActive; if (context.SaveChanges() > 0) { result = true; } } } catch (Exception e) { } return(result); }
public int CreateSurvey(BirdSurvey item) { int newid = 0; try { using (RCID_DWHEntities context = new RCID_DWHEntities()) { newid = context.Bird_Survey.OrderByDescending(u => u.SurveyID).FirstOrDefault().SurveyID; newid++; Bird_Survey efItem = new Bird_Survey() { SurveyID = newid, ClimateID = item.ClimateID, SamplePointAreaID = item.SamplePointAreaID, SourceID = item.SourceID == 0? LIMS_SOURCEID:item.SourceID, SurveyDate = item.SurveyDate, SurveyorID = item.SurveyorID }; context.Bird_Survey.Add(efItem); if (context.SaveChanges() > 0) { return(newid); } } } catch (Exception e) { throw e; } return(newid); }
public void TestBirdSurveyInvaild() { BirdSurvey survey = new BirdSurvey( new DateTime(2020, 11, 24), new DateTime(2020, 10, 24, 10, 35, 00), new DateTime(2020, 10, 24, 10, 35, 00), new Site(1, "Rock Pool", "Pool"), new[] { new Sighting(1, "Magpie", "3") }, "Comments"); Assert.False(survey.VaildforBirdSurvey()); }
public string DeleteSurvey(BirdSurvey item) { string msg = string.Empty; try { if (ModelState.IsValid) { _birdSvc.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")] BirdSurvey item) { string msg = string.Empty; try { if (ModelState.IsValid) { _birdSvc.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 InactivateSurvey(BirdSurvey item) { return(_birdRepo.InactivateSurvey(item)); }
public bool CreateSurvey(BirdSurvey item) { return(_birdRepo.CreateSurvey(item) > 0); }
public bool UpdateSurvey(BirdSurvey item) { return(_birdRepo.UpdateSurvey(item)); }
public static List <BirdSurvey> ParseFile(string filepath) { List <BirdSurvey> surveyList = new List <BirdSurvey>(); try { using (XLWorkbook workBook = new XLWorkbook(filepath)) { IXLWorksheet workSheet = workBook.Worksheet(1); foreach (IXLRow row in workSheet.Rows()) { switch (row.RowNumber()) { //first three rows are survey headers case 1: foreach (IXLCell cell in row.Cells()) { string value = cell.Value.ToString(); //starting a survey if (!value.Equals("Observer")) { BirdSurvey item = new BirdSurvey(); item.SurveyorName = value; //TODO remove this line! there should be a way to get the climate id for this item item.ClimateID = 1; surveyList.Add(item); } } break; case 2: foreach (IXLCell cell in row.Cells()) { string value = cell.Value.ToString(); //add date to survey if (!value.Equals("Date")) { DateTime date = cell.GetDateTime(); BirdSurvey item = surveyList[cell.Address.ColumnNumber - 2]; item.SurveyDate = date; } } break; case 3: foreach (IXLCell cell in row.Cells()) { string value = cell.Value.ToString(); //add date to survey if (!value.Equals("Location")) { BirdSurvey item = surveyList[cell.Address.ColumnNumber - 2]; item.SamplePointAreaName = value; } } break; // after three rows, survey details start default: string speciesName = ""; foreach (IXLCell cell in row.Cells()) { //all rows except the last one which is a total row if (cell.Address.ColumnNumber == 1) { speciesName = cell.Value.ToString(); if (speciesName.Equals("TOTAL SPECIES")) { break; } //this is the last row } else { if (!cell.IsEmpty()) { BirdSurvey parent = surveyList[cell.Address.ColumnNumber - 2]; BirdSurveyDetails detail = new BirdSurveyDetails(); detail.SpeciesName = speciesName; detail.SurveyDetailCount = cell.Value.CastTo <int>(); if (parent.Details == null) { parent.Details = new List <BirdSurveyDetails>(); } parent.Details.Add(detail); } } } break; } } } return(surveyList); } catch (Exception e) { throw e; } }