public ActionResult Edit(Calibration calibration) { if (ModelState.IsValid) { HttpPostedFileBase filephoto = Request.Files[0]; if (filephoto != null) { Stream fs = filephoto.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); calibration.CalibReportpdf = bytes; } //SendMail(Calibration.HandedOverToEmail); //Calibration.MailStatus = TempData["Mailstatus"].ToString(); equipmentContext.Entry(calibration).State = EntityState.Modified; if (calibration.CalibReportpdf == null) { equipmentContext.Entry(calibration).Property(x => x.CalibReportpdf).IsModified = false; } equipmentContext.SaveChanges(); // SendMail(handover.HandedOverToEmail); return(RedirectToAction("Index")); } return(View()); }
public async Task <EquipmentBrand> GetAsync(int equipmentBrand) { var equipmentsBrand = await _context.EquipmentBrand.FindAsync(equipmentBrand); if (equipmentsBrand != null) { await _context.Entry(equipmentsBrand) .Collection(i => i.Name).LoadAsync(); } return(equipmentsBrand); }
public async Task <EquipmentType> GetAsync(int equipmentType) { var equipmentsType = await _context.EquipmentType.FindAsync(equipmentType); if (equipmentsType != null) { await _context.Entry(equipmentsType) .Collection(i => i.Name).LoadAsync(); } return(equipmentsType); }
public async Task <Equipments> GetAsync(int equipmentsId) { var equipments = await _context.Equipments.FindAsync(equipmentsId); if (equipments != null) { await _context.Entry(equipments) .Collection(i => i.Name).LoadAsync(); await _context.Entry(equipments) .Reference(i => i.Code).LoadAsync(); } return(equipments); }
public async Task <IActionResult> PutInvoice(int id, Invoice invoice) { if (id != invoice.InvoiceId) { return(BadRequest()); } _context.Entry(invoice).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: Asset public ActionResult Index(string id, string sortOrder) { ViewBag.CurrentSort = sortOrder; ViewBag.AssetSortParm = String.IsNullOrEmpty(sortOrder) ? "asset_desc" : ""; ViewBag.DescriptionSortParm = sortOrder == "description" ? "description_desc" : "description"; var viewModel = new AssetIndexData(); viewModel.Assets = db.Assets .Include(i => i.WorkOrders) .OrderBy(i => i.AssetID); switch (sortOrder) { case "asset_desc": viewModel.Assets = viewModel.Assets.OrderByDescending(s => s.AssetID); break; case "description": viewModel.Assets = viewModel.Assets.OrderBy(s => s.Description); break; case "description_desc": viewModel.Assets = viewModel.Assets.OrderByDescending(s => s.Description); break; default: viewModel.Assets = viewModel.Assets.OrderBy(s => s.AssetID); break; } if (!String.IsNullOrEmpty(id)) { ViewBag.AssetID = id; var selectedAsset = viewModel.Assets.Where(x => x.AssetID == id).Single(); db.Entry(selectedAsset).Collection(x => x.WorkOrders).Load(); foreach (WorkOrder workOrder in selectedAsset.WorkOrders) { db.Entry(workOrder).Reference(x => x.Asset).Load(); } viewModel.WorkOrders = selectedAsset.WorkOrders; } return(View(viewModel)); }
public ActionResult Edit([Bind(Include = "WorkOrderID,AssetID,Problem,DateRequested")] WorkOrder workOrder) { if (ModelState.IsValid) { db.Entry(workOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AssetID = new SelectList(db.Assets, "AssetID", "Description", workOrder.AssetID); return(View(workOrder)); }
public ActionResult Edit(HandOver handover, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { Stream fs = file.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); handover.Photo = bytes; } SendMail(handover.HandedOverToEmail, handover.RecivedTo); handover.MailStatus = TempData["Mailstatus"].ToString(); equipmentContext.Entry(handover).State = EntityState.Modified; equipmentContext.SaveChanges(); // SendMail(handover.HandedOverToEmail); return(RedirectToAction("Index")); } GetDropwnList(); return(View()); }
public ActionResult Edit(Models.Equipment equipment) { if (ModelState.IsValid) { //Models.Equipment obj = new Models.Equipment(); //obj = equipmentContext.Equipments.Single(objid => objid.Id == equipment.Id); HttpPostedFileBase filephoto = Request.Files[0]; HttpPostedFileBase fileOperatingInstructionpdf = Request.Files[1]; HttpPostedFileBase fileDatasheetpdf = Request.Files[2]; HttpPostedFileBase fileCataloguepdf = Request.Files[3]; if (filephoto.FileName != "") { byte[] bytes; using (BinaryReader br = new BinaryReader(filephoto.InputStream)) { bytes = br.ReadBytes(filephoto.ContentLength); } equipment.Photo = bytes; } if (fileOperatingInstructionpdf.FileName != "") { Stream fs = fileOperatingInstructionpdf.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); equipment.OperatingInstructionpdf = bytes; } if (fileDatasheetpdf.FileName != "") { Stream fs = fileDatasheetpdf.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); equipment.Datasheetpdf = bytes; } if (fileCataloguepdf.FileName != "") { Stream fs = fileCataloguepdf.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); equipment.Cataloguepdf = bytes; } equipmentContext.Entry(equipment).State = EntityState.Modified; if (equipment.Photo == null) { equipmentContext.Entry(equipment).Property(x => x.Photo).IsModified = false; } if (equipment.OperatingInstructionpdf == null) { equipmentContext.Entry(equipment).Property(x => x.OperatingInstructionpdf).IsModified = false; } if (equipment.Cataloguepdf == null) { equipmentContext.Entry(equipment).Property(x => x.Cataloguepdf).IsModified = false; } if (equipment.Datasheetpdf == null) { equipmentContext.Entry(equipment).Property(x => x.Datasheetpdf).IsModified = false; } equipmentContext.SaveChanges(); return(RedirectToAction("Index")); } GetDropwnList(); return(View()); }
public void Update(Equipment equipment) { _context.Entry(equipment).State = EntityState.Modified; }