// // GET: /Inventory/Delete/5 public ActionResult Delete(int PropertyInventoryID) { ViewBag.PropertyInventoryID = PropertyInventoryID; propertyinventory inventory = PropertyInventoryRepository.GetInventoryByID(PropertyInventoryID); return(View(inventory)); }
public ActionResult DeleteConfirmed(int PropertyInventoryID) { propertyinventory inventory = PropertyInventoryRepository.GetInventoryByID(PropertyInventoryID); if (inventory.PictureID > 0) { picture picture = PictureRepository.GetPictureByID((int)inventory.PictureID); PictureRepository.DeleteRecord(picture); } if (inventory.DocumentID > 0) { document document = DocumentRepository.GetDocumentByID((int)inventory.DocumentID); DocumentRepository.DeleteRecord(document); } PropertyInventoryRepository.DeleteRecord(inventory); return(RedirectToAction("Details")); }
public ActionResult Edit(int PropertyInventoryID) { GetData(); propertyinventory inventory = PropertyInventoryRepository.GetInventoryByID(PropertyInventoryID); /* * inventory.ReturnBeginDate = ReturnBeginDate; * inventory.ReturnEndDate = ReturnEndDate; * inventory.ReturnSearchType = ReturnSearchType; * inventory.ReturnCodeID = ReturnCodeID; * inventory.ReturnCode = ReturnCode; * inventory.ReturnCodeID2 = ReturnCodeID2; * inventory.ReturnLowValue = ReturnLowValue; * inventory.ReturnHighValue = ReturnHighValue; * inventory.ReturnMethod = ReturnMethod; * */ return(PartialView(inventory)); }
public ActionResult Create(propertyinventory inventory) { try { if (inventory.Comment == null) { inventory.Comment = ""; } if (ModelState.IsValid) { db.propertyinventories.Add(inventory); db.SaveChanges(); TempData["Message2"] = "Property inventory added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding property inventory"; } GetData(); return(PartialView(inventory)); }
public ActionResult Edit(propertyinventory inventory) { string ReturnUrl = Request.UrlReferrer.ToString(); try { if (inventory.Comment == null) { inventory.Comment = ""; } if (ModelState.IsValid) { //add property picture picture pic = new picture(); foreach (var image in inventory.files) { if (image != null) { pic.ImageMimeType = image.ContentType; pic.ImageData = new byte[image.ContentLength]; image.InputStream.Read(pic.ImageData, 0, image.ContentLength); pic.ministryID = 0; pic.PictureDate = System.DateTime.Today; pic.Status = "Active"; pic.Description = string.Format("Picture:{0}", inventory.Title); pic.DateEntered = System.DateTime.Today; pic.EnteredBy = User.Identity.Name.ToString(); db.pictures.Add(pic); db.SaveChanges(); PictureRepository.AddRecord(pic); inventory.PictureID = pic.pictureID; } } //document foreach (var file in inventory.documentFile) { if (file != null && file.ContentLength > 0) { int documentTypeID = ConstantRepository.GetConstantByName("Property Document").constantID; // Get file info document document = new document(); document.Title = string.Format("{0} document", inventory.Title); document.DocumentTypeID = documentTypeID; document.Status = "Active"; document.EnteredBy = User.Identity.Name.ToString(); document.DateEntered = System.DateTime.Today; document.FileName = Path.GetFileName(file.FileName); document.ContentLength = file.ContentLength; document.ContentType = file.ContentType; document.Author = "Property Document"; var path = Path.Combine(Server.MapPath("~/App_Data/ClientFiles"), document.FileName); //var path = Path.Combine(Server.MapPath("~/public_html/ClientFiles"), document.FileName); file.SaveAs(path); db.documents.Add(document); db.SaveChanges(); inventory.DocumentID = document.documentID; } } db.Entry(inventory).State = EntityState.Modified; db.SaveChanges(); // PropertyInventoryRepository.AddRecord(inventory); TempData["Message2"] = string.Format("Property record update successfully.", inventory.Title); GetData(); //return Redirect("/Home/Admin?Page=Property"); //return Redirect("/PropertyInventory/PropertyInventoryCategoryList?categoryID=" + inventory.propertyID); return(Redirect(ReturnUrl)); } } catch (Exception ex) { TempData["Message2"] = string.Format("Error editing {0} record.", inventory.Title); } GetData(); return(PartialView(inventory)); }
public propertyinventory GetInventoryByID(int inventoryID) { record = myRecords.FirstOrDefault(e => e.propertyInventoryID == inventoryID); return(record); }
public void AddRecord(propertyinventory Record) { myRecords.Add(record); }
public void DeleteRecord(propertyinventory record) { myRecords.Remove(record); context.propertyinventories.Remove(record); context.SaveChanges(); }