示例#1
0
        public static ItemViewModel ConvertFromDto(BodyguardDto dto)
        {
            var model = new ItemViewModel();

            if (dto != null)
            {
                model.Index      = index++;
                model.IsReadOnly = true;
                model.ID         = dto.ID;
                model.Phone      = dto.Phone;
                model.IsMale     = dto.IsMale;
                model.Name       = string.Join(" ", dto.FirstName, dto.SurName, dto.LastName);

                switch (rand.Next(2))
                {
                case 0:
                    model.Category = "A";
                    break;

                case 1:
                    model.Category = "B";
                    break;

                case 2:
                    model.Category = "C";
                    break;
                }
            }

            return(model);
        }
示例#2
0
        private BodyguardDto ConvertToDto()
        {
            var dto = new BodyguardDto()
            {
                Address        = Address,
                BirthDate      = BirthDate,
                CategoryId     = CategoryId,
                City           = City,
                DriverLicense  = DriverLicense,
                FirstName      = FirstName,
                Height         = Height,
                IsEnglish      = IsEnglish,
                ID             = _id,
                IsMale         = IsMale,
                IsRiffle       = IsRiffle,
                IsShortGun     = IsShortGun,
                LastName       = LastName,
                PersonalWeapon = PersonalWeapon,
                Phone          = Phone,
                SurName        = SurName,
                Weight         = Weight
            };

            return(dto);
        }
示例#3
0
        public void Save(BodyguardDto dto)
        {
            Task.Run(() =>
            {
                var existDto = _bodyguardCollection.FirstOrDefault(x => x.ID == dto.ID);
                if (existDto != null)
                {
                    var index = _bodyguardCollection.ToList().IndexOf(existDto);
                    _bodyguardCollection.ToList().Remove(existDto);
                    _bodyguardCollection.ToList().Insert(index, dto);
                }
                else
                {
                    _bodyguardCollection.ToList().Add(dto);
                }

                _eventAggregator.GetEvent <RepositoryEvents.BodyguardRepositoryChanged>().Publish();
            });
        }
示例#4
0
 private void ConvertFromDto(BodyguardDto dto)
 {
     Address        = dto.Address;
     BirthDate      = dto.BirthDate;
     CategoryId     = dto.CategoryId;
     City           = dto.City;
     DriverLicense  = dto.DriverLicense;
     FirstName      = dto.FirstName;
     Height         = dto.Height;
     IsEnglish      = dto.IsEnglish;
     _id            = dto.ID;
     IsMale         = dto.IsMale;
     IsRiffle       = dto.IsRiffle;
     IsShortGun     = dto.IsShortGun;
     LastName       = dto.LastName;
     PersonalWeapon = dto.PersonalWeapon;
     Phone          = dto.Phone;
     SurName        = dto.SurName;
     Weight         = dto.Weight;
 }