示例#1
0
        public IHttpActionResult DeleteSolutionOffers(DeleteSoltuionOfferModel offer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            SolutionOffer _offer     = null;
            string        measureId  = offer.Measure_id;
            string        solutionId = offer.Solution_id;

            using (SoilCareEntities db = new SoilCareEntities())
            {
                _offer = db.SolutionOffers.Where(s => s.Measure_id.Equals(measureId) && s.Solution_id.Equals(solutionId))
                         .FirstOrDefault <SolutionOffer>();
                if (_offer == null)
                {
                    db.Dispose();
                    return(NotFound());
                }
                _offer.Status = "Deleted";

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    throw;
                }
            }
            return(Ok());
        }
        // Get: api/Solutions/solutionid
        public IHttpActionResult GetSolutionById(string id)
        {
            SolutionModel _solution = null;

            using (SoilCareEntities db = new SoilCareEntities())
            {
                Solution solution = db.Solutions.Find(id);
                if (solution == null)
                {
                    db.Dispose();
                    return(NotFound());
                }
                _solution = Mapper.Map <Solution, SolutionModel>(solution);
            }
            return(Ok(_solution));
        }
        // Delete: api/Lands/landId
        public IHttpActionResult DeleteLand(string id)
        {
            Land _land = null;

            using (SoilCareEntities db = new SoilCareEntities())
            {
                _land = db.Lands.Find(id);
                if (_land == null)
                {
                    db.Dispose();
                    return(NotFound());
                }
                _land.Status = "Deleted";
                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    throw;
                }
            }
            return(Ok());
        }