Пример #1
0
        public virtual ActionResult Edit(ProfileEditModel model)
        {
            var user = MapToUserDTO(model);

            _intranetUserService.Update(user);

            return(RedirectToCurrentUmbracoPage());
        }
Пример #2
0
        public ActionResult Edit(ExtendedProfileEditModel model)
        {
            var user   = MapToUserDTO(model);
            var tagIds = model.TagIdsData.ParseStringCollection(Guid.Parse);

            _userTagService.Replace(user.Id, tagIds);
            _intranetUserService.Update(user);
            return(RedirectToCurrentUmbracoPage());
        }
Пример #3
0
 public virtual IHttpActionResult Update(UpdateUserDto updateModel)
 {
     if (ModelState.IsValid)
     {
         return(_intranetUserService.Update(updateModel)
             ? (IHttpActionResult)Ok()
             : NotFound());
     }
     else
     {
         return(BadRequest(GetModelErrors()));
     }
 }
Пример #4
0
        private void SaveUsers(string domain, bool updateExisting,
                               UserCredential userCredential, out Exception exception)
        {
            exception = null;
            try
            {
                var service = new DirectoryService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = userCredential,
                    ApplicationName       = "Uintra"
                });

                var request = service.Users.List();
                request.Domain  = domain;
                request.OrderBy = UsersResource.ListRequest.OrderByEnum.Email;
                var users = request.Execute().UsersValue.ToList();

                foreach (var user in users)
                {
                    var email        = user.Emails.First().Address;
                    var existingUser = _intranetUserService.GetByEmail(email);

                    if (existingUser != null)
                    {
                        if (updateExisting)
                        {
                            var updateUserDto = user.Map <UpdateUserDto>();
                            updateUserDto.Id       = existingUser.Id;
                            updateUserDto.NewMedia = GetMediaId(user, service);
                            _intranetUserService.Update(updateUserDto);
                        }
                    }
                    else
                    {
                        var createUserDto = user.Map <CreateUserDto>();
                        createUserDto.MediaId = GetMediaId(user, service);
                        _intranetUserService.Create(createUserDto);
                    }
                }
            }
            catch (Exception e)
            {
                exception = e;
            }
        }