Пример #1
0
        public OperationResult Edit(EditGuest command)
        {
            var operation = new OperationResult();

            operation.IsSuccedded = false;
            var editItem = _guestRepository.Get(command.Id);

            if (editItem == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }
            if (_guestRepository.Exist(x => x.FullName == command.FullName && x.Id != command.Id))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            var slug = command.FullName.Slugify();

            var ImageFolderName = Tools.ToFolderName(this.GetType().Name);
            var ImagePath       = $"{ImageFolderName}/{slug}";
            var imageFileName   = _fileUploader.Upload(command.Image, ImagePath);

            editItem.Edit(command.FullName, command.Tel, command.Email, imageFileName, command.ImageAlt,
                          command.ImageTitle, command.GuestType, command.Coordinator);
            _guestRepository.SaveChanges();
            return(operation.Succedded());
        }
Пример #2
0
 public CreateUserViewModel(bool edit, INotificationService notificationService, IGuestRepository guestRepository = null, int guestId = 0) : this()
 {
     GuestRepository     = guestRepository;
     NotificationService = notificationService;
     if (!edit)
     {
         DisplayTitle = "Create new User";
         AcceptButton = "Create";
         IsEdit       = false;
         Guest        = new Guest();
     }
     else
     {
         DisplayTitle  = "Edit User";
         AcceptButton  = "Edit";
         IsEdit        = true;
         Guest         = GuestRepository.Get(guestId);
         _firstName    = Guest.FirstName;
         _lastname     = Guest.Lastname;
         _phone        = Guest.PhoneNumber;
         _userName     = Guest.Username;
         _passwordHash = Guest.PasswordHash;
         _dateOfBirth  = Guest.DateOfBirth;
     }
 }
Пример #3
0
 // GET: GuestList
 public async Task <IActionResult> Index(int?id)
 {
     if (id == null)
     {
         return(View());
     }
     return(View(_guestRepository.Get((int)id, new GuestOptionsBuilder())));
 }
Пример #4
0
        public async Task GetGuests()
        {
            var guests = _guestRepo.Get(new Wedding(), null);

            Assert.IsTrue(guests != null);
        }