public ActionResult Items() { var db = new ApplicationDbItem(); var list = db.GetItems(10); return(View("~/Views/Home/Items.cshtml", list)); }
public ActionResult Item(int id) { var db = new ApplicationDbItem(); var item = db.GetItemById(id); return(View("~/Views/Home/Item.cshtml", item)); }
// GET: Item public ActionResult CreateItem(Item item) { string path = ""; string imgpath = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds().ToString() + ".jpg"; try { if (item.itemPath != null) { string pic = System.IO.Path.GetFileName(item.itemPath.FileName); // file is uploaded path = System.IO.Path.Combine( Server.MapPath("~/Assets/images/Items"), imgpath); item.itemPath.SaveAs(path); } var tipas = (enumItemType)Enum.Parse(typeof(enumItemType), item.tipas, true); item.tipas = tipas .GetType() .GetMember(tipas.ToString()) .FirstOrDefault() ?.GetCustomAttribute <DescriptionAttribute>() ?.Description ?? tipas.ToString(); } catch (Exception e) { throw; } var db = new ApplicationDbItem(); db.CreateItem(item, imgpath); return(View("~/Views/Home/NewItem.cshtml")); }