コード例 #1
0
ファイル: CompanyController.cs プロジェクト: patrickwensel/WS
        public ActionResult CompanyDestroy([DataSourceRequest] DataSourceRequest request, EntityViewModel entityViewModel)
        {
            try
            {
                if (entityViewModel != null)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        //Video video = (from v in context.Videos
                        //               where v.ID == locationViewModel.ID
                        //               select v).FirstOrDefault();

                        //context.Videos.Remove(video);
                        //context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }

            return Json(ModelState.ToDataSourceResult());
        }
コード例 #2
0
ファイル: CompanyController.cs プロジェクト: patrickwensel/WS
        public ActionResult EntityUpdate([DataSourceRequest] DataSourceRequest dataSourceRequest, EntityViewModel entityViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        Entity entity = (from v in context.Entities
                                         where v.ID == entityViewModel.ID
                                       select v).FirstOrDefault();

                        if (entity != null)
                        {
                            entity.LocationID = entityViewModel.LocationID;
                            entity.StatusID = entityViewModel.StatusID;
                            entity.Name = entityViewModel.Name;
                            entity.Code = entityViewModel.Code;
                            entity.CostCenter = entityViewModel.CostCenter;

                            context.SaveChanges();
                        }
                    }

                }
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
            return Json(new[] { entityViewModel }.ToDataSourceResult(dataSourceRequest, ModelState));
        }
コード例 #3
0
ファイル: CompanyController.cs プロジェクト: patrickwensel/WS
        public ActionResult EntityCreate([DataSourceRequest] DataSourceRequest request, EntityViewModel entityViewModel)
        {
            try
            {
                if (entityViewModel != null && ModelState.IsValid)
                {
                    using (ASJDE context = new ASJDE())
                    {

                        Entity entity = new Entity
                            {
                                LocationID = entityViewModel.LocationID,
                                StatusID = entityViewModel.StatusID,
                                Name = entityViewModel.Name,
                                Code = entityViewModel.Code,
                                CostCenter = entityViewModel.CostCenter

                            };

                        context.Entities.Add(entity);
                        context.SaveChanges();
                        entityViewModel.ID = entity.ID;
                    }
                }

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

            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
                return null;
            }
        }
コード例 #4
0
ファイル: CompanyController.cs プロジェクト: patrickwensel/WS
        public ActionResult EntityDestroy([DataSourceRequest] DataSourceRequest request, EntityViewModel entityViewModel)
        {
            try
            {
                if (entityViewModel != null)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        Entity entity = (from v in context.Entities
                                         where v.ID == entityViewModel.ID
                                         select v).FirstOrDefault();

                        context.Entities.Remove(entity);
                        context.SaveChanges();

                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }

            return Json(ModelState.ToDataSourceResult());
        }
コード例 #5
0
ファイル: CompanyController.cs プロジェクト: patrickwensel/WS
        public ActionResult CompanyUpdate([DataSourceRequest] DataSourceRequest dataSourceRequest, EntityViewModel entityViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        //Video video = (from v in context.Videos
                        //               where v.ID == locationViewModel.ID
                        //               select v).FirstOrDefault();

                        //if (video != null)
                        //{
                        //    video.Name = locationViewModel.Name;
                        //    video.VideoGroupID = locationViewModel.GroupID;
                        //    video.ReferenceID = locationViewModel.ReferenceID;

                        //    context.SaveChanges();
                        //}
                    }

                }
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
            return Json(new[] { entityViewModel }.ToDataSourceResult(dataSourceRequest, ModelState));
        }