public ActionResult Create(Beer beer) { try { beer.Type = "beer"; beer.Updated = DateTime.Now; beer.Id = beer.Name.Replace(' ', '_').ToLower(); Repository.Save(beer); return(RedirectToAction("Index")); } catch (CouchbaseDataException e) { ViewBag.Success = false; ViewBag.Message = e.Message; ViewBag.Status = e.Status; return(View(beer)); } }
public ActionResult Create(Beer beer) { try { _repository.Save(beer); return(RedirectToAction("Index")); } catch { return(View()); } }
public void Test_Create() { using (var cluster = new Cluster()) { using (var bucket = cluster.OpenBucket("beer-sample")) { var repository = new BeerRepository(bucket); var beer = new Couchbase.Data.RepositoryExample.Models.Beer { Id = "bud_light", Name = "Bud Light", Type = "beer" }; repository.Save(beer); } } }