コード例 #1
0
 public void Save(WorkerHouseRelation obj)
 {
     if (obj.Id == 0)
         context.Entry(obj).State = System.Data.Entity.EntityState.Added;
     else
         context.Entry(obj).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }
コード例 #2
0
        public ActionResult AddRelatedHouse(WorkerHouseRelation obj)
        {
            if(ModelState.IsValid)
            {
                dataManager.WorkerHouseRelations.Save(obj);
                return RedirectToAction("Show", new { Id = obj.WorkerId });
            }

            ViewBag.Houses = from h in dataManager.Houses.GetAll()
                             select new SelectListItem
                             {
                                 Text = h.Name,
                                 Value = h.Id.ToString()
                             };
            return View(obj);
        }