public ActionResult UpdateUnitStatus(int id, bool ProductUnitStatus) { MVCProductUnitModel ProductunitModel = new MVCProductUnitModel(); ProductunitModel.ProductUnitID = id; try { if (ProductUnitStatus == true) { ProductunitModel.Status = false; } else { ProductunitModel.Status = true; } HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("UpdateUnitStatus/", ProductunitModel).Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { return(Json(response.StatusCode, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ex.ToString(); } return(View()); }
public ActionResult CheckUnitStatus(string name) { List <MVCProductUnitModel> ProductUnitmodel = new List <MVCProductUnitModel>(); MVCProductUnitModel ProductunitModel = new MVCProductUnitModel(); ProductunitModel.ProductUnit = name; if (name != null) { CheckUnit1 objectcount = new CheckUnit1(); int CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("APIProductUnitByName/" + CompanyId, ProductunitModel).Result; objectcount = response.Content.ReadAsAsync <CheckUnit1>().Result; if (objectcount.count > 0) { return(Json("Found", JsonRequestBehavior.AllowGet)); } else { return(Json("NotFound", JsonRequestBehavior.AllowGet)); } } else { return(Json("NotFound Name", JsonRequestBehavior.AllowGet)); } }
public ActionResult AddorEdit(int id) { if (id == 0) { return(View(new MVCProductUnitModel())); } else { HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetProductUnitByID/" + id).Result; MVCProductUnitModel MvcUnitModel = response.Content.ReadAsAsync <MVCProductUnitModel>().Result; return(Json(MvcUnitModel, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddorEdit(MVCProductUnitModel unitmodel) { if (unitmodel.ProductUnitID == null) { unitmodel.CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("PostProductUnit", unitmodel).Result; return(Json(response.StatusCode, JsonRequestBehavior.AllowGet)); } else { unitmodel.CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage response = GlobalVeriables.WebApiClient.PutAsJsonAsync("PutProductUnit/" + unitmodel.ProductUnitID, unitmodel).Result; return(Json(response.StatusCode, JsonRequestBehavior.AllowGet)); } }
public IHttpActionResult GetProductUnitbyId(int id) { try { MVCProductUnitModel obProductUnit = db.ProductUnitTables.Where(x => x.ProductUnitID == id).Select(c => new MVCProductUnitModel { ProductUnitID = c.ProductUnitID, ProductUnit = c.ProductUnit, Status = c.Status, CompanyId = c.CompanyId, }).FirstOrDefault(); return(Ok(obProductUnit)); } catch (Exception ex) { return(NotFound()); } }