Ejemplo n.º 1
0
        public ActionResult GetPageTypes()
        {
            List <Nomenclature> types;

            using (ContextManager.NewConnection())
            {
                types = nomenclatureService.Get("npagetype");
            }

            return(new JsonResultMaxLength(types));
        }
 public ActionResult GetStatuses()
 {
     using (ContextManager.NewConnection())
     {
         var data = nomenclatureService.Get("nsupplierstatus");
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 3
0
        public JsonResult Nomenclature(string name)
        {
            List <Nomenclature> result;

            using (ContextManager.NewConnection())
            {
                result = nomenclatureService.Get(name).ToList();
            }

            return(new JsonResultMaxLength(result));
        }
Ejemplo n.º 4
0
        protected override void InitialQuery(PollQueryViewModel model)
        {
            List <Nomenclature> statuses;

            using (ContextManager.NewConnection())
            {
                statuses = nomenclatureService.Get("nquestionnairestatus");
            }

            model.StatusDataSource = statuses
                                     .Select(
                status => new KeyValuePair <string, string>(status.Id?.ToString(), status.Name))
                                     .ToList().AddDefaultValue(false);
        }
Ejemplo n.º 5
0
 protected override void InitialQuery(FaqQueryViewModel model)
 {
     using (ContextManager.NewConnection())
     {
         var categories = Mapper.Map <List <FaqCategoryViewModel> >(faqService.SearchFaqCategories());
         model.CategoryDataSource = categories
                                    .Select(
             item => new KeyValuePair <string, string>(item.Id?.ToString(), item.Name))
                                    .ToList().AddDefaultValue();
         model.StatusDataSource = nomenclatureService.Get("nfaqstatus")
                                  .Select(
             item => new KeyValuePair <string, string>(item.Id?.ToString(), item.Name))
                                  .ToList().AddDefaultValue();
     }
 }
        protected override void InitialQuery(PublicationQueryModel model)
        {
            List <Nomenclature> statuses;

            using (ContextManager.NewConnection())
            {
                statuses = nomenclatureService.Get("nnewtype").ToList();
            }

            model.TypeIdDataSource = statuses
                                     .Select(item => new KeyValuePair <string, string>(item.Id?.ToString(), item.Name))
                                     .ToList();
            model.TypeIdDataSource.Insert(0, new KeyValuePair <string, string>(null, Resource.All));

            model.IsVisibleDataSource = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(null, Resource.All),
                new KeyValuePair <string, string>("true", Resource.Yes),
                new KeyValuePair <string, string>("false", Resource.No)
            };
        }
Ejemplo n.º 7
0
        public ActionResult Upsert(Guid?id)
        {
            var model = new UserUpsertViewModel();

            List <Nomenclature> profiles;

            using (ContextManager.NewConnection())
            {
                ViewBag.Roles = roleService.Search(new RoleQuery {
                    UserId = User.Id
                });
                profiles = nomenclatureService.Get("nrolegnw");

                if (id.HasValue)
                {
                    model       = Mapper.Map <UserUpsertViewModel>(userService.Get(id.Value));
                    model.Roles = roleService.GetUserRoles(id.Value);
                }
            }

            //// when register user there is no geonetwork account yet
            if (model.GeoNetworkId.HasValue)
            {
                using (var client = restApiService.GetClient())
                {
                    var geoNetworkUser = restApiService.GetRequest <UserDTO>(client, $"users/{model.GeoNetworkId}");

                    model.IsAdministrator = geoNetworkUser.Profile == Enum.GetName(
                        typeof(GeoNetWorkProfile),
                        GeoNetWorkProfile.Administrator);

                    model.GeoNetworkAddress = geoNetworkUser.Addresses?.FirstOrDefault();

                    if (!model.IsAdministrator)
                    {
                        var geoNetworkUserGroups = restApiService.GetRequest <List <UserGroup> >(
                            client,
                            $"users/{model.GeoNetworkId}/groups");
                        var firstGroupId = geoNetworkUserGroups.FirstOrDefault()?.Id;

                        model.Group = new GroupForUser
                        {
                            Id = firstGroupId?.GroupId
                        };

                        model.Profile = profiles?.Single(
                            item => item.Id.Equals(
                                EnumHelper.GetProfileIdByProfile(
                                    (GeoNetWorkProfile)Enum.Parse(
                                        typeof(GeoNetWorkProfile),
                                        firstGroupId?.Profile,
                                        true))));
                    }
                }
            }

            this.InitAdminBreadcrumb(
                Title,
                string.Format(
                    model.Id.HasValue
                        ? string.Format(Resource.Editing, model.UserName)
                        : string.Format(Resource.Creating, Resource.User.ToLower())),
                true);

            return(Request.IsAjaxRequest()
                ? PartialView(model) as ActionResult
                : View(model));
        }