public IHttpActionResult GetCropSteps_Material(int id)
        {
            CropSteps_Material cropSteps_Material = db.CropSteps_Material.Find(id);

            if (cropSteps_Material == null)
            {
                return(NotFound());
            }

            return(Ok(cropSteps_Material));
        }
        public HttpResponseMessage PostCropSteps_Material(CropSteps_Material cropSteps_Material)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            db.CropSteps_Material.Add(cropSteps_Material);
            db.SaveChanges();

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = cropSteps_Material.Id }, success = true, error = string.Empty }));
        }
        public IHttpActionResult DeleteCropSteps_Material(int id)
        {
            CropSteps_Material cropSteps_Material = db.CropSteps_Material.Find(id);

            if (cropSteps_Material == null)
            {
                return(NotFound());
            }

            db.CropSteps_Material.Remove(cropSteps_Material);
            db.SaveChanges();

            return(Ok(cropSteps_Material));
        }
        public HttpResponseMessage PutCropSteps_Material(int id, CropSteps_Material cropSteps_Material)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            if (id != cropSteps_Material.Id)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            try
            {
                CropSteps_Material Cultivation_MaterialData = db.CropSteps_Material.Where(a => a.Id == id).FirstOrDefault();
                Cultivation_MaterialData.Material_Name        = cropSteps_Material.Material_Name;
                Cultivation_MaterialData.Step_Id              = cropSteps_Material.Step_Id;
                Cultivation_MaterialData.Quantity             = cropSteps_Material.Quantity;
                Cultivation_MaterialData.Material_Transaction = cropSteps_Material.Material_Transaction;
                Cultivation_MaterialData.Per_Decimal_Price    = cropSteps_Material.Per_Decimal_Price;
                Cultivation_MaterialData.Active = cropSteps_Material.Active;
                if (cropSteps_Material.UpdatedBy != null)
                {
                    Cultivation_MaterialData.UpdatedBy = cropSteps_Material.UpdatedBy;
                    Cultivation_MaterialData.UpdatedOn = cropSteps_Material.UpdatedOn;
                }
                if (cropSteps_Material.ActiveBy != null)
                {
                    Cultivation_MaterialData.ActiveBy = cropSteps_Material.ActiveBy;
                    Cultivation_MaterialData.ActiveOn = cropSteps_Material.ActiveOn;
                }
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CropSteps_MaterialExists(id))
                {
                    return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.NotFound, new { data = new { string.Empty }, success = false, error = string.Empty }));
                }
                else
                {
                    throw;
                }
            }

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { cropSteps_Material }, success = true, error = string.Empty }));
        }
        public HttpResponseMessage UpdateMaterialImage(CropSteps_Material cropSteps_Material)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            //if (id != cropSteps_Material.Id)
            //{
            //    return (HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty });
            //}

            try
            {
                CropSteps_Material Cultivation_MaterialData = db.CropSteps_Material.Where(a => a.Id == cropSteps_Material.Id).FirstOrDefault();
                Cultivation_MaterialData.Image_Path = cropSteps_Material.Image_Path;
                if (cropSteps_Material.UpdatedBy != null)
                {
                    Cultivation_MaterialData.UpdatedBy = cropSteps_Material.UpdatedBy;
                    Cultivation_MaterialData.UpdatedOn = cropSteps_Material.UpdatedOn;
                }
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CropSteps_MaterialExists(cropSteps_Material.Id))
                {
                    return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.NotFound, new { data = new { string.Empty }, success = false, error = string.Empty }));
                }
                else
                {
                    throw;
                }
            }

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { cropSteps_Material }, success = true, error = string.Empty }));
        }