Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public bool CreateSurvey(FishSurvey item)
 {
     return(_fishRepo.CreateSurvey(item) > 0);
 }
Exemplo n.º 7
0
 public bool UpdateSurvey(FishSurvey item)
 {
     return(_fishRepo.UpdateSurvey(item));
 }
Exemplo n.º 8
0
 public bool InactivateSurvey(FishSurvey item)
 {
     return(_fishRepo.InactivateSurvey(item));
 }