public IHttpActionResult EditBrands(string id, [Bind(Include = "Id,BrandName,BrandStory,PhoneNumber,Sort,LinePay,CarImage,LogoPhoto,OrCode,FbAccount")] ViewBrand viewBrand) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Brand brand = new Brand(); int id_temp = Convert.ToInt32(id); brand = db.Brands.Where(x => x.Id == id_temp).FirstOrDefault(); brand.BrandName = viewBrand.BrandName; brand.BrandStory = viewBrand.BrandStory; brand.PhoneNumber = viewBrand.PhoneNumber; brand.Sort = viewBrand.Sort; brand.LinePay = viewBrand.LinePay; brand.CarImage = viewBrand.CarImage; brand.LogoPhoto = viewBrand.LogoPhoto; brand.QrCode = viewBrand.QrCode; brand.FbAccount = viewBrand.FbAccount; db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(Ok(new { brand, sort = brand.Sort.ToString(), result = true, message = "新增修改成功" })); }
public List <ViewBrand> GetAll() { //fetch db.animal data, and pull all rows table into RAM var brands = db.Brands.ToList(); //convert this data into view data var viewBrands = new List <ViewBrand>(); foreach (var li in brands) { var viewBrand = new ViewBrand(li); viewBrands.Add(viewBrand); } //return return(viewBrands); }
public IHttpActionResult PatchBrands(string id, [Bind(Include = "Id,Verification")] ViewBrand viewBrand) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Brand brand = new Brand(); int id_temp = Convert.ToInt32(id); brand = db.Brands.Where(x => x.Id == id_temp).FirstOrDefault(); brand.Verification = viewBrand.Verification; db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(Ok(new { result = true, message = "修改成功" })); }
// GET: Brand/Details/5 public ActionResult Details(int id) { ViewBrand viewBrand = dal.Get(id); return(View(viewBrand)); }