public ActionResult CreateResource(ResourcesAdminViewModel model) { try { ResourcesAdminModel addResource = new ResourcesAdminModel { Name = model.Name, Description = model.Description, Type = model.Type }; if (model.image.ContentLength > 0) { string _FileName = Path.GetFileName(model.image.FileName); string _path = Path.Combine(Server.MapPath("~/Content/Images/Resources"), _FileName); model.image.SaveAs(_path); addResource.Image = _path; } db.AdminResources.Add(addResource); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult RequestAnItem(int id) { ResourcesAdminModel model = db.AdminResources.Where(i => i.Id == id).FirstOrDefault(); var viewModel = new ResourcesRequestViewModel() { id = model.Id, type = model.Type, ResourceName = model.Name, Qty = 0, Comment = "", Urgent = false }; return(View(viewModel)); }