Exemple #1
0
 public async Task AddGuest([FromBody][Required] GuestBindingModel guest)
 {
     GuestInfo guestInfo = new GuestInfo()
     {
         Name  = guest.Email,
         Email = guest.Email
     };
     await hotelDAO.AddGuestAsync(guestInfo);
 }
Exemple #2
0
        public async Task <IActionResult> Save([FromBody] GuestBindingModel model)
        {
            var entity = _mapper.Map <Guest>(model);

            entity.CreatedBy     = UserId;
            entity.Email         = model.EmailPersonal.NotNullOrEmpty() ? model.EmailPersonal : model.EmailCorp;
            entity.PlainPassword = ExtensionMethods.GeneratePassword(6, 1);
            entity.Password      = _passwordHasher.Hash(entity.PlainPassword);

            if (await _repository.ExistsAsync(x => x.Email == entity.Email))
            {
                return(BadRequest(new BadRequestResponseModel(ErrorTypes.BadRequest, "There is already one guest with this email")));
            }

            await _repository.AddAsync(entity);

            return(Ok());
        }
Exemple #3
0
        public async Task <GuestBindingModel> AddGuestAsync([FromBody][Required] GuestBindingModel guest)
        {
            IEnumerable <Guest> result = await UnitOfWork.Guest.GetByEmailAsync(guest.Email);

            List <Guest> guests = result.ToList();

            if (guests.Any())
            {
                throw new Exception("Guest already exists");
            }
            Guest guestInfo = new Guest()
            {
                Name  = guest.Email,
                Email = guest.Email
            };
            await UnitOfWork.Guest.AddAsync(guestInfo);

            guest.GuestId = guestInfo.Id;
            return(guest);
        }
Exemple #4
0
        public async Task <IActionResult> UpdateGuest([FromBody] GuestBindingModel model)
        {
            var entity = await _repository.FindAsync(model.Id);

            if (entity == null)
            {
                return(BadRequest(new BadRequestResponseModel(ErrorTypes.BadRequest, ErrorMessages.ItemNotFound)));
            }

            entity.FirstName     = model.FirstName;
            entity.LastName      = model.LastName;
            entity.LinkedinUrl   = model.LinkedinUrl;
            entity.PhoneCorp     = model.PhoneCorp;
            entity.PhonePersonal = model.PhonePersonal;
            entity.EmailCorp     = model.EmailCorp;
            entity.EmailPersonal = model.EmailPersonal;
            entity.Email         = model.EmailPersonal.NotNullOrEmpty() ? model.EmailPersonal : model.EmailCorp;
            entity.UpdatedAt     = DateTime.Now;
            entity.UpdatedBy     = UserId;

            await _repository.UpdateAsync(entity);

            return(Ok());
        }