public void IsInvalid_User()
 {
     var item = new UserDto()
     {
         FirstName = string.Empty,
         LastName = string.Empty,
     };
     Assert.IsFalse(item.IsValid());
 }
 public static BusinessCardViewModel CreateFrom(UserDto user)
 {
     return Mapper.Map<UserDto, BusinessCardViewModel>(user);
 }
 public void IsValid_User()
 {
     var item = new UserDto()
     {
         FirstName = Guid.NewGuid().ToString(),
         LastName = Guid.NewGuid().ToString(),
     };
     Assert.IsTrue(item.IsValid());
 }
 public void Update(UserDto item)
 {
     new Updator(this.Session).Update(item);
 }
Exemple #5
0
        /// <summary>
        /// Create the specified item into the database
        /// </summary>
        /// <param name="item">The item to add in the database</param>
        public long Create(UserDto item)
        {
            Assert.IsNotNull(item, "item");

            var found = (from p in this.Session.Query<User>()
                         where p.Id == item.Id
                         select p).ToList().Count() > 0;
            if (found) throw new ExistingItemException();

            if (item.IsDefault) this.ReplaceDefaultUser();

            this.Session.Flush();

            var entity = Mapper.Map<UserDto, User>(item);
            if (string.IsNullOrWhiteSpace(entity.Password)) throw new EmptyPasswordException();

            if (this.IsFirstUser()) { entity.IsSuperAdmin = true; }

            item.Id = (long)this.Session.Save(entity);
            return item.Id;
        }
        public void Refresh()
        {
            try
            {
                if (PluginContext.Host.ConnectedUser == null) return;

                this.Practices = this.component.GetAllPractices().ToObservableCollection();
                this.Roles = this.component.GetAllRolesLight().ToObservableCollection();

                var user = this.component.LoadUser(PluginContext.Host.ConnectedUser);
                this.User = user;

                if (this.User.Practice != null)
                {
                    this.SelectedPractice = (from p in this.Practices
                                             where p.Id == this.User.Practice.Id
                                             select p).FirstOrDefault();
                }

                PluginContext.Host.WriteStatus(StatusType.Info, Messages.Msg_Ready);
            }
            catch (Exception ex) { this.Handle.Error(ex); }
        }