Exemplo n.º 1
0
        public string DeleteSpecies(PhytoSpecies item)
        {
            string msg = string.Empty;

            item.SpeciesActive = false;

            try
            {
                if (ModelState.IsValid)
                {
                    _PhytoSvc.InactivateSpecies(item);
                    msg = "Species inactivated succesfully";
                }
                else
                {
                    msg = "Data validation not successfull";
                }
            }
            catch (Exception e)
            {
                msg = "Delete Species. An error has ocurred";
            }

            return(msg);
        }
Exemplo n.º 2
0
        public bool InactivateSpecies(PhytoSpecies item)
        {
            bool result = false;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    Phyto_Species efItem = context.Phyto_Species.Where(b => b.SpeciesID == item.SpeciesID).FirstOrDefault();

                    if (efItem == null)
                    {
                        return(result);
                    }

                    efItem.SpeciesActive = false;

                    if (context.SaveChanges() > 0)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception) { }
            return(result);
        }
Exemplo n.º 3
0
        public bool CreateSpecies(PhytoSpecies item)
        {
            bool result = false;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    short newid = context.Phyto_Species.OrderByDescending(u => u.SpeciesID).FirstOrDefault().SpeciesID;
                    newid++;

                    Phyto_Species efItem = new Phyto_Species()
                    {
                        SpeciesID     = newid,
                        SpeciesActive = true,
                        SpeciesName   = item.SpeciesName,
                        DivisionID    = item.DivisionID
                    };

                    context.Phyto_Species.Add(efItem);

                    if (context.SaveChanges() > 0)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception e) { throw e; }
            return(result);
        }
Exemplo n.º 4
0
        public string CreateSpecies([Bind(Exclude = "SpeciesID")] PhytoSpecies item)
        {
            string msg = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    _PhytoSvc.CreateSpecies(item);
                    msg = "Species created succesfully";
                }
                else
                {
                    msg = "Data validation not successfull";
                }
            }
            catch (Exception e)
            {
                msg = "Create Species. An error has ocurred";
            }

            return(msg);
        }
Exemplo n.º 5
0
        public string EditSpecies(PhytoSpecies item)
        {
            string msg = "Edit Species. An error has ocurred";

            try
            {
                if (!ModelState.IsValid)
                {
                    msg = "Data validation not successfull";
                    return(msg);
                }

                if (_PhytoSvc.UpdateSpecies(item))
                {
                    msg = "Species saved succesfully";
                }
            }
            catch (Exception e) {
                msg = "Edit Species. An error has ocurred";
            }

            return(msg);
        }
Exemplo n.º 6
0
 public bool InactivateSpecies(PhytoSpecies item)
 {
     return(_PhytoRepo.InactivateSpecies(item));
 }
Exemplo n.º 7
0
 public bool CreateSpecies(PhytoSpecies item)
 {
     return(_PhytoRepo.CreateSpecies(item));
 }
Exemplo n.º 8
0
 public bool UpdateSpecies(PhytoSpecies item)
 {
     return(_PhytoRepo.UpdateSpecies(item));
 }