Ejemplo n.º 1
0
        public ActionResult Edit(BindingEditViewModel model) {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list bindings")))
                return new HttpUnauthorizedResult();

            if (ModelState.IsValid) {

                var binding = _repository.Get(model.Id);

                if (binding == null) {
                    return HttpNotFound();
                }

                binding.DisplayName = model.Display;
                binding.Description = model.Description;

                Services.Notifier.Information(T("Binding updated successfully"));

                return RedirectToAction("Index");
            }

            return View("Edit", model);
        }
Ejemplo n.º 2
0
        public ActionResult CreatePost(BindingEditViewModel model) {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list bindings")))
                return new HttpUnauthorizedResult();
        
            if(ModelState.IsValid) {

                _repository.Create(new MemberBindingRecord {
                    Type = model.FullName,
                    Member = model.Member,
                    DisplayName =  model.Display,
                    Description = model.Description
                });

                Services.Notifier.Information(T("Binding created successfully"));

                return RedirectToAction("Index");
            }

            return View("Edit", model);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id) {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list bindings")))
                return new HttpUnauthorizedResult();

            var binding = _repository.Get(id);

            if (binding == null) {
                return HttpNotFound();
            }

            var recordBluePrints = _sessionFactoryHolder.GetSessionFactoryParameters().RecordDescriptors;

            var record = recordBluePrints.FirstOrDefault(r => String.Equals(r.Type.FullName, binding.Type, StringComparison.OrdinalIgnoreCase));

            if (record == null) {
                Services.Notifier.Information(T("The record for this binding is no longer available, please remove it."));
                return RedirectToAction("Index");
            }

            var property = record.Type.GetProperty(binding.Member, BindingFlags.Instance | BindingFlags.Public);

            if (property == null) {
                Services.Notifier.Information(T("The member for this binding is no longer available, please remove it."));
                return RedirectToAction("Index");
            }

            var model = new BindingEditViewModel {
                Id = id,
                FullName = record.Type.FullName,
                Member = property.Name,
                Display = binding.DisplayName,
                Description = binding.Description
            };

            return View("Edit", model);
        }
Ejemplo n.º 4
0
        public ActionResult Create(string fullName, string member) {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list bindings")))
                return new HttpUnauthorizedResult();

            var recordBluePrints = _sessionFactoryHolder.GetSessionFactoryParameters().RecordDescriptors;

            var record = recordBluePrints.FirstOrDefault(r => r.Type.FullName.Equals(fullName, StringComparison.OrdinalIgnoreCase));

            if(record == null) {
                return HttpNotFound();
            }

            var property = record.Type.GetProperty(member, BindingFlags.Instance | BindingFlags.Public);

            if (property == null) {
                return HttpNotFound();
            }

            var model = new BindingEditViewModel {
                Id = -1,
                FullName = record.Type.FullName,
                Member = property.Name
            };

            return View("Edit", model);
        }