public ActionResult Details(int?id) { if (id == null) { return(StatusCode(400)); } foods food = _foodManager.Find(x => x.id == id.Value); ViewBag.Categories = _categoryManager.List(); IQueryable <stars> rate = _rateManager.ListQueryable().Where(x => x.fokey == food.foodkey); // TODO: Var i değiştir. foreach (var item in rate) { puan = puan + item.rate; say++; } ViewBag.Rate = puan / say; if (food == null) { return(StatusCode(404)); } return(View(food)); }
protected void btnFoodAdd_Click(object sender, EventArgs e) { string fileName = Guid.NewGuid().ToString() + ".jpg"; foodPicUpload.SaveAs(Server.MapPath("~/pics/" + fileName)); var ifb = new iFoodBoxDataContext(); var addfoods = new foods(); addfoods.foodName = tbFoodName.Text; addfoods.foodType = rdofoodType.SelectedItem.Value.ToString(); addfoods.foodCount = int.Parse(tbFoodCount.Text); addfoods.foodPicPath = fileName; addfoods.foodDate = DateTime.Parse(tbFoodDate.Text); addfoods.foodDeadline = DateTime.Parse(tbFoodDeadline.Text); addfoods.foodalarmDay = int.Parse(cboSetFoodAlert.SelectedItem.Value); addfoods.foodFreezing = int.Parse(cboFoodPosition.SelectedItem.Value); addfoods.iFoodBoxID = 1; //chi 還沒寫 ifb.foods.InsertOnSubmit(addfoods); ifb.SubmitChanges(); Response.Redirect("ManageFood.aspx"); }
public ActionResult DeleteConfirmed(int id) { foods food = _foodManager.Find(x => x.id == id); _foodManager.Delete(food); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(long id) { foods foods = db.foods.Find(id); db.foods.Remove(foods); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult down(foods mm, long?field_name) { //设置上架 foods foods = db.foods.Find(field_name); foods.sale_status = 0; db.SaveChanges(); return(View("Index", GetAllFoods())); }
public ActionResult Edit([Bind(Include = "id,merchant_id,name,sequence,pic,price,desc,approval_status,reject_reason,sale_status,join_discount,join_buy_gift,created_at,updated_at")] foods foods) { if (ModelState.IsValid) { db.Entry(foods).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(foods)); }
public ActionResult Create(foods food) { if (ModelState.IsValid) { food.id = null; _foodManager.Insert(food); return(RedirectToAction("Index")); } return(View(food)); }
public ActionResult up(foods mm, long field_name) { //if (mm == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //设置上架 foods foods = db.foods.Find(field_name); foods.sale_status = 1; db.SaveChanges(); return(View("Index", GetAllFoods())); }
// GET: foods/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } foods foods = db.foods.Find(id); if (foods == null) { return(HttpNotFound()); } return(View(foods)); }
public ActionResult Delete(int?id) { if (id == null) { return(StatusCode(400)); } foods food = _foodManager.Find(x => x.id == id.Value); if (food == null) { return(StatusCode(404)); } return(View(food)); }
public ActionResult Edit(int?id) { if (id == null) { return(StatusCode(400)); } foods food = _foodManager.Find(x => x.id == id.Value); ViewBag.Categories = _categoryManager.List(); if (food == null) { return(StatusCode(404)); } return(View(food)); }
public ActionResult Edit(foods food) { if (ModelState.IsValid) { foods findFood = _foodManager.Find(x => x.id == food.id); findFood.foodkey = food.foodkey; findFood.foodname = food.foodname; findFood.categorykey = food.categorykey; findFood.isapproved = food.isapproved; _foodManager.Update(findFood); return(RedirectToAction("Index")); } return(View(food)); }
public JsonResult AltKategoriYeni(SubCategoriesAddDTO entity) { try { foods kategori = new foods(); kategori.food_catagory_id = entity.food_catagory_id; kategori.food_name = entity.food_name; kategori.food_status = true; db.foods.Add(kategori); db.SaveChanges(); return(Json(kategori, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(null); } }
public ActionResult Create([Bind(Include = "id,merchant_id,name,sequence,pic,price,desc,approval_status,reject_reason,sale_status,join_discount,join_buy_gift,created_at,updated_at")] foods foods, HttpPostedFileBase file_input) { if (ModelState.IsValid) { try { if (file_input != null && file_input.ContentLength > 0) { string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + Path.GetFileName(file_input.FileName); string filePath = Path.Combine(Server.MapPath("~/Upload"), fileName); file_input.SaveAs(filePath); foods.pic = "~/Upload/" + fileName; foods.merchant_id = (int)Session["merchant_id"]; foods.approval_status = 0; foods.sale_status = 1;//上架 foods.join_discount = false; foods.join_buy_gift = false; foods.created_at = DateTime.Now; foods.updated_at = DateTime.Now; db.foods.Add(foods); db.SaveChanges(); } else { return(Content("没有文件!", "text/plain")); } } catch { return(Content("上传异常 !", "text/plain")); } return(View("Index", GetAllFoods())); } return(View("Index", GetAllFoods())); }
partial void Insertfoods(foods instance);
partial void Updatefoods(foods instance);
partial void Deletefoods(foods instance);