public ActionResult Edit(Employee employee, HttpPostedFileBase file) { AssetLogic al = new AssetLogic(); if (ModelState.IsValid) { var _employee = _context.Employees.Find(employee.employeeNumber); if (file != null && file.ContentLength > 0) { employee.fileName = System.IO.Path.GetFileName(file.FileName); employee.fileType = file.ContentType; employee.fileBytes = al.ConvertToBytes(file); } else { employee.fileName = _employee.fileName; employee.fileType = _employee.fileType; employee.fileBytes = _employee.fileBytes; } employee.fullname = employee.firstName + " " + employee.lastName; _context.Entry(_employee).State = EntityState.Detached; _context.Entry(employee).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("UserProfile")); } ViewBag.RoleID = new SelectList(_context.Roles, "RoleID", "RoleName", employee.RoleID); ViewBag.departmentID = new SelectList(_context.Departments, "departmentID", "departmentName", employee.departmentID); return(View(employee)); }
public IHttpActionResult DeleteAssetAllocationDetailsById(int id, int LastModifiedBy, string Comments) { long AssetAllocId = 0; AssetAllocation objAssetAllocation = db.AssetAllocations.Find(id); if (objAssetAllocation == null) { return(NotFound()); } AssetAllocId = objAssetAllocation.AssetAllocationId; var qry = db.AssetAllocations.Where(x => x.AssetAllocationId == AssetAllocId).ToList(); qry.ForEach(e => e.AssetCanceledOn = System.DateTime.Now); qry.ForEach(y => y.LastModifiedBy = LastModifiedBy); qry.ForEach(y => y.LastModifiedOn = System.DateTime.Now); qry.ForEach(z => z.CancellationComments = Comments); db.Entry(objAssetAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssetAllocationExists(id)) { return(NotFound()); } else { throw; } } return(Ok("Updated")); }
public IHttpActionResult DeleteAssetTypeSpecification(int id, int LastModifiedBy) { AssetTypeSpecification objAssetTypeSpecification = db.AssetTypeSpecifications.Find(id); if (objAssetTypeSpecification == null) { return(NotFound()); } objAssetTypeSpecification.IsActive = false; objAssetTypeSpecification.LastModifiedOn = System.DateTime.Now; objAssetTypeSpecification.LastModifiedBy = LastModifiedBy; db.Entry(objAssetTypeSpecification).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssetTypeExists(id)) { return(NotFound()); } else { throw; } } return(Ok(objAssetTypeSpecification)); }
// PUT api/AssetCategory/5 public IHttpActionResult PutAssetCategory(int id, AssetCategory assetCategory, int LastModifiedBy) { if (id != assetCategory.Id) { return(BadRequest()); } assetCategory.LastModifiedOn = System.DateTime.Now; assetCategory.LastModifiedBy = LastModifiedBy; db.Entry(assetCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssetCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "replacementPartID,name,associatedAsset,associatedTicket,invoiceNumber,supplier,price,partNumber,pruchaseDate")] ReplacementPart replacementPart) { if (ModelState.IsValid) { db.Entry(replacementPart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(replacementPart)); }
public ActionResult Edit([Bind(Include = "ID,FirstName,LastName")] Employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Edit([Bind(Include = "ID,Name,POID,StatusID,LicenseNo")] Software software) { if (ModelState.IsValid) { db.Entry(software).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.PurchaseOrders, "ID", "PO_Number", software.ID); ViewBag.StatusID = new SelectList(db.Status, "ID", "Description", software.StatusID); return(View(software)); }
public ActionResult Edit([Bind(Include = "ID,Type,Model,ServiceTag,POID,LabelName,StatusID")] Hardware hardware) { if (ModelState.IsValid) { db.Entry(hardware).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.POID = new SelectList(db.PurchaseOrders, "ID", "PO_Number", hardware.POID); ViewBag.StatusID = new SelectList(db.Status, "ID", "Description", hardware.StatusID); ViewBag.Type = new SelectList(db.Types, "ID", "Description", hardware.Type); return(View(hardware)); }
public ActionResult Ticket(string id, string solution) { var _context = new AssetManagementEntities(); var ticket = _context.Tickets.Find(int.Parse(id)); ticket.datecompleted = DateTime.Now; ticket.accomplishstatus = true; ticket.ticketstatus = true; ticket.solution = solution; _context.Entry(ticket).State = EntityState.Modified; _context.SaveChanges(); TempData["Success"] = "Ticket has been completed"; return(RedirectToAction("Ticket")); }
public ActionResult Edit(AssignmentVM assignmentVM) { if (ModelState.IsValid) { db.Entry(assignmentVM.assignment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "FirstName", assignment.EmployeeID); //ViewBag.HardwareID = new SelectList(db.Hardwares, "ID", "Model", assignment.HardwareID); //ViewBag.SoftwareID = new SelectList(db.Softwares, "ID", "Name", assignment.SoftwareID); //ViewBag.VisioID = new SelectList(db.Softwares, "ID", "Name", assignment.VisioID); return(View(assignmentVM)); }
public void UpdateEntity(TEntity entity) { _dbSet.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }