public RatingVo update(RatingVo input, Guid?ratingId = null) { using (var db = new MainDb()) { if (ratingId == null) { ratingId = input.ratingId; } var res = db.ratings.FirstOrDefault(e => e.ratingId == ratingId); if (res == null) { return(null); } input.created = res.created; // input.createdBy = res.createdBy; db.Entry(res).CurrentValues.SetValues(input); db.SaveChanges(); return(res); } }
public RatingVo insert(RatingVo input) { using (var db = new MainDb()) { db.ratings.Add(input); db.SaveChanges(); return(input); } }
public ActionResult Edit(Guid id, RatingVo input) { if (this.ModelState.IsValid) { var res = ratingManager.update(input, id); return(RedirectToAction("Index")); } return(View(input)); }
public ActionResult Create(RatingVo input) { if (this.ModelState.IsValid) { var item = ratingManager.insert(input); return(RedirectToAction("Index")); } return(View(input)); }
public ActionResult Create() { var vo = new RatingVo(); return(View(vo)); }