public ActionResult DeleteConfirmed(int id) { DeptMaster deptMaster = db.DeptMasters.Find(id); db.DeptMasters.Remove(deptMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DeptId,DeptName,DeptCode")] DeptMaster deptMaster) { if (ModelState.IsValid) { db.Entry(deptMaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deptMaster)); }
public ActionResult Create([Bind(Include = "DeptId,DeptName,DeptCode")] DeptMaster deptMaster) { if (ModelState.IsValid) { db.DeptMasters.Add(deptMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deptMaster)); }
public IActionResult Put([FromBody] DeptMaster req) { bool result = _repo.Update(req); if (result) { return(Ok("Success")); } return(Ok("Fail")); }
// GET: DeptMasters/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DeptMaster deptMaster = db.DeptMasters.Find(id); if (deptMaster == null) { return(HttpNotFound()); } return(View(deptMaster)); }
public FileInfoModel GetFileInfo() { connection = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(); DataSet ds = new DataSet(); FileInfoModel infoModel = new FileInfoModel(); infoModel.DepartmentList = new List <DeptMaster>(); infoModel.SubDeptList = new List <SubDeptMaster>(); try { cmd = new SqlCommand("sp_GetFileDetails", connection); cmd.CommandType = CommandType.StoredProcedure; adp.SelectCommand = cmd; connection.Open(); adp.Fill(ds); connection.Close(); foreach (DataRow dr in ds.Tables[0].Rows) { DeptMaster dMaster = new DeptMaster(); dMaster.Id = Convert.ToInt32(dr["Id"].ToString()); dMaster.Name = dr["Name"].ToString(); infoModel.DepartmentList.Add(dMaster); } foreach (DataRow dr in ds.Tables[1].Rows) { SubDeptMaster sMaster = new SubDeptMaster(); sMaster.Id = Convert.ToInt32(dr["Id"].ToString()); sMaster.Name = dr["Name"].ToString(); infoModel.SubDeptList.Add(sMaster); } infoModel.DeptId = 0; infoModel.SubDeptId = 0; } catch (Exception ex) { Console.WriteLine(ex); } return(infoModel); }