[HttpPost] public ActionResult EditInfra(InfraStructure postInfra) { var infra = Convert.ToInt32(Session["Infra_id"]); _helper.ExecuteInsertStmtusingSp("spEditInfra", "@id", infra.ToString(), "@catid", postInfra.CategoryId.ToString(), "@Infraname", postInfra.InfraName, "@Qty", postInfra.Quantity.ToString()); return(RedirectToAction("SaveInfraStructureDetails")); }
public IHttpActionResult PutInfraStructure(int id, InfraStructure infraStructure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != infraStructure.InfraStructures_id) { return(BadRequest()); } db.Entry(infraStructure).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InfraStructureExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetInfraStructure(int id) { InfraStructure infraStructure = db.InfraStructures.Find(id); if (infraStructure == null) { return(NotFound()); } return(Ok(infraStructure)); }
public IHttpActionResult DeleteInfraStructure(int id) { InfraStructure infraStructure = db.InfraStructures.Find(id); if (infraStructure == null) { return(NotFound()); } db.InfraStructures.Remove(infraStructure); db.SaveChanges(); return(Ok(infraStructure)); }
[HttpPost] public int SaveInfraStructureDetails(InfraStructure infraModel) { var returnVal = 0; var workshopquery = "select workshop_id from m_employees where employeeId=" + Session["Employee_Id"] + ""; var dtWorkshop = _helper.ExecuteSelectStmt(workshopquery); var workshopId = dtWorkshop.AsEnumerable().Select(x => x.Field <int>("workshop_id")).FirstOrDefault(); var infraDetails = new InfraStructure { InfraName = infraModel.InfraName, CategoryId = infraModel.CategoryId, Quantity = infraModel.Quantity, WorkShopId = workshopId, Cost = infraModel.Cost }; if (ModelState.IsValid) { returnVal = _helper.ExecuteInsertStmtusingSp("InsetInfraDetails", "@CategoryId", infraDetails.CategoryId.ToString(), "@qty", infraDetails.Quantity.ToString(), "@InfraName", infraDetails.InfraName, "@workshopid", infraDetails.WorkShopId.ToString(), null, null, null, null, null, null, null, null, "@cost", infraDetails.Cost.ToString()); } return(returnVal); }
[HttpGet] public ActionResult EditInfra(int?id = null) { if (id == null) { return(RedirectToAction("SaveInfraStructureDetails")); } const string infraQuery = "select * from m_infra_category"; var dtinfra = _helper.ExecuteSelectStmt(infraQuery); var model = new InfraStructure(); var dsEditInfra = Session["InfraTable"] as DataSet; if (dsEditInfra != null) { var row = dsEditInfra.Tables[0].AsEnumerable().ToList().Single(x => x.Field <int>("infra_id") == id); model.infra_id = Convert.ToInt32(row["infra_id"]); Session["Infra_id"] = model.infra_id; model.InfraName = row["infra_name"].ToString(); model.CategoryName = row["category_name"].ToString(); model.Quantity = Convert.ToInt32(row["quantity"]); } model.Category = new SelectList(dtinfra.AsDataView(), "category_id", "category_name"); return(View(model)); }