コード例 #1
0
 public ActionResult Create()
 {
     var model = new SampleViewModel();
     model.Image.Width = 100;
     model.Image.Height = 100;
     return View(model);
 }
コード例 #2
0
        public ActionResult Edit(int id, SampleViewModel model)
        {
            var context = new MainContext();
            var sample = context.Samples.FirstOrDefault(s => s.Id == id);
            sample = Mapper.Map(model, sample);
            context.SaveChanges();

            return RedirectToAction("Index");
        }
コード例 #3
0
        public ActionResult Create(SampleViewModel model)
        {
            var entity = Mapper.Map<Sample>(model);
            var context = new MainContext();
            context.Samples.Add(entity);
            context.SaveChanges();

            return RedirectToAction("Index");
        }