public ActionResult DeleteConfirmed(int id) { TPIAllocation tPIAllocation = db.TPIAllocations.Find(id); db.TPIAllocations.Remove(tPIAllocation); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: TPIAllocations/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TPIAllocation tPIAllocation = db.TPIAllocations.Find(id); if (tPIAllocation == null) { return(HttpNotFound()); } return(View(tPIAllocation)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TPIAllocation tPIAllocation = db.TPIAllocations.Find(id); db.TPIAllocations.Remove(tPIAllocation); db.SaveChanges(); if (tPIAllocation == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "id,title,employeeId,companyId,vendorId,LocationId,date,start,finish,status,remark")] TPIAllocation tPIAllocation) { if (ModelState.IsValid) { tPIAllocation.title = DateTime.Now.ToString("yyMMddhhmmss"); db.TPIAllocations.Add(tPIAllocation); db.SaveChanges(); return(RedirectToAction("Index")); } //var catEmployees = db.Employees.Where(x => x.categoryId == category); ViewBag.companyId = new SelectList(db.Companies, "id", "companyName", tPIAllocation.companyId); ViewBag.vendorId = new SelectList(db.Vendors, "id", "name"); ViewBag.LocationId = new SelectList(db.Locations, "id", "name"); var employee = db.Employees.Select(x => new { id = x.id, employeeId = x.employeeId + "-" + x.name }); ViewBag.employeeId = new SelectList(employee, "id", "employeeId", tPIAllocation.employeeId); return(View(tPIAllocation)); }
public ActionResult Edit([Bind(Include = "id,title,employeeId,vendorId,LocationId,companyId,date,start,finish,status,remark")] TPIAllocation tPIAllocation) { if (ModelState.IsValid) { if (tPIAllocation.status == "Completed" && tPIAllocation.finish == null) { tPIAllocation.finish = DateTime.Now; } db.Entry(tPIAllocation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.companyId = new SelectList(db.Companies, "id", "companyName", tPIAllocation.companyId); ViewBag.vendorId = new SelectList(db.Vendors, "id", "name"); ViewBag.LocationId = new SelectList(db.Locations, "id", "name"); var employee = db.Employees.Select(x => new { id = x.id, employeeId = x.employeeId + "-" + x.name }); ViewBag.employeeId = new SelectList(employee, "id", "employeeId", tPIAllocation.employeeId); return(View(tPIAllocation)); }
// GET: TPIAllocations/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TPIAllocation tPIAllocation = db.TPIAllocations.Find(id); if (tPIAllocation == null) { return(HttpNotFound()); } ViewBag.companyId = new SelectList(db.Companies, "id", "companyName", tPIAllocation.companyId); ViewBag.vendorId = new SelectList(db.Vendors, "id", "name"); ViewBag.LocationId = new SelectList(db.Locations, "id", "name"); var employee = db.Employees.Select(x => new { id = x.id, employeeId = x.employeeId + "-" + x.name }); ViewBag.employeeId = new SelectList(employee, "id", "employeeId", tPIAllocation.employeeId); // ViewBag.date = "01/07/2020 0:00:00"; return(View(tPIAllocation)); }