예제 #1
0
        public ActionResult ScrapReasons_Create([DataSourceRequest]DataSourceRequest request, ScrapReason scrapReason)
        {
            if (ModelState.IsValid)
            {
                var entity = new ScrapReason
                {
                    Name = scrapReason.Name,
                    ModifiedDate = DateTime.Now
                };

                db.ScrapReasons.Add(entity);
                db.SaveChanges();
                scrapReason.ScrapReasonID = entity.ScrapReasonID;
            }

            return Json(new[] { scrapReason }.ToDataSourceResult(request, ModelState));
        }
예제 #2
0
        public ActionResult ScrapReasons_Destroy([DataSourceRequest]DataSourceRequest request, ScrapReason scrapReason)
        {
            if (ModelState.IsValid)
            {
                var entity = new ScrapReason
                {
                    ScrapReasonID = scrapReason.ScrapReasonID,
                    Name = scrapReason.Name,
                    ModifiedDate = scrapReason.ModifiedDate
                };

                db.ScrapReasons.Attach(entity);
                db.ScrapReasons.Remove(entity);
                db.SaveChanges();
            }

            return Json(new[] { scrapReason }.ToDataSourceResult(request, ModelState));
        }
예제 #3
0
        public ActionResult ScrapReasons_Update([DataSourceRequest]DataSourceRequest request, ScrapReason scrapReason)
        {
            if (ModelState.IsValid)
            {
                var entity = new ScrapReason
                {
                    ScrapReasonID = scrapReason.ScrapReasonID,
                    Name = scrapReason.Name,
                    ModifiedDate = DateTime.Now
                };

                db.ScrapReasons.Attach(entity);
                db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return Json(new[] { scrapReason }.ToDataSourceResult(request, ModelState));
        }