예제 #1
0
        public ActionResult Details(int id)
        {
            BusinessObjectDetails model;

            if (id > 0)
            {
                var bo = _BOdb.BusinessObjects.Find(id);

                //string viewData = readViewData(bo.VirtualPath);

                model = new BusinessObjectDetails()
                {
                    Id = bo.Id, Name = bo.Name, JsonSchema = bo.JsonSchema, DefaultData = bo.DefaultData, ViewData = bo.ViewData
                };                                                                                                                                                     // ,ViewData = viewData };
            }
            else
            {
                model = new BusinessObjectDetails()
                {
                    Id = -1, Name = "Name", DefaultData = "", JsonSchema = "", ViewData = ""
                };                                                                                                                  // ,ViewData = viewData };
            }

            return(View(model));
        }
예제 #2
0
        public ActionResult Details(BusinessObjectDetails model)
        {
            BO_BusinessObject bo;

            bool writeaccess = false;

            if (model.Id > 0)
            {
                bo          = _BOdb.BusinessObjects.Find(model.Id);
                writeaccess = (_BOdb.BusinessObjectInstances.Count(r => r.BusinessObjectId == model.Id) == 0);
            }
            else
            {
                bo          = new BO_BusinessObject();
                writeaccess = true;
            }


            if (writeaccess)
            {
                bo.Name        = model.Name;
                bo.DefaultData = model.DefaultData;
                bo.JsonSchema  = model.JsonSchema;
                bo.ViewData    = model.ViewData;



                if (model.Id < 0)
                {
                    _BOdb.BusinessObjects.Add(bo);
                }
                _BOdb.SaveChanges();

                /*if (model.Id < 0)
                 * {
                 *  bo.VirtualPath = "/Views/BORepository/bo" + bo.Id + ".cshtml";
                 *  _BOdb.SaveChanges();
                 * }*/

                //writeViewData(bo.VirtualPath, model.ViewData);
            }

            return(RedirectToAction("Index"));
        }