public BidderRegistrationResponseDto TryToRegister(BidderRegistrationRequestDto dto)
        {
            if (uow.Users.GetAll().Where(x => x.Username == dto.Email).FirstOrDefault() != null)
                throw new System.Exception("Invalid Email Address");

            var user = new User()
            {
                Username = dto.Email,
                Firstname = dto.Firstname,
                Lastname = dto.Lastname,
                Password = encryptionService.TransformPassword(dto.Password),
            };

            uow.Users.Add(user);

            var account = new Account()
            {
                Firstname = dto.Firstname,
                Lastname = dto.Lastname,
                Email = dto.Email,
                AccountType = AccountType.Bidder,
                User = user,
                AccountStatus = AccountStatus.Unpaid
            };

            user.Accounts.Add(account);

            Profile profile = Map(dto.Firstname, dto.Lastname,account,dto.BidderType);

            account.Profiles.Add(profile);

            Bidder bidder = CreateBidder(dto, profile, uow);

            uow.SaveChanges();

            var response = new BidderRegistrationResponseDto()
            {
                Firstname = bidder.Firstname,
                Lastname = bidder.Lastname,
                Id = bidder.Id
            };

            return response;
        }
        public Bidder CreateBidder(BidderRegistrationRequestDto dto, Profile profile, IWeddingBiddersUow uow)
        {
            Bidder bidder = null;

            if (dto.BidderType == BidderType.Caterer)
            {
                bidder = new Caterer()
                {
                    Firstname = dto.Firstname,
                    Lastname = dto.Lastname,
                    Profile = profile,
                    Email = dto.Email,
                    CompanyName = dto.CompanyName
                };

                var gallery = new Gallery() { Name = "Profile" };
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_1.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_2.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_3.jpg" });
                bidder.Galleries.Add(gallery);

                uow.Caterers.Add(bidder as Caterer);
            }

            if (dto.BidderType == BidderType.EventPlanner)
            {
                bidder = new EventPlanner()
                {
                    Firstname = dto.Firstname,
                    Lastname = dto.Lastname,
                    Profile = profile,
                    Email = dto.Email
                };

                var gallery = new Gallery() { Name = "Profile" };
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_1.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_2.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_3.jpg" });
                bidder.Galleries.Add(gallery);

                uow.EventPlanners.Add(bidder as EventPlanner);
            }

            if (dto.BidderType == BidderType.MakeUpArtist)
            {
                bidder = new MakeUpArtist()
                {
                    Firstname = dto.Firstname,
                    Lastname = dto.Lastname,
                    Profile = profile,
                    Email = dto.Email
                };

                var gallery = new Gallery() { Name = "Profile" };
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_1.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_2.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_3.jpg" });
                bidder.Galleries.Add(gallery);

                uow.MakeUpArtists.Add(bidder as MakeUpArtist);
            }

            if (dto.BidderType == BidderType.Photographer)
            {
                bidder = new Photographer()
                {
                    Firstname = dto.Firstname,
                    Lastname = dto.Lastname,
                    Profile = profile,
                    Email = dto.Email,
                    CompanyName = dto.CompanyName
                };

                var gallery = new Gallery() { Name = "Profile" };
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_1.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_2.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_3.jpg" });
                bidder.Galleries.Add(gallery);

                uow.Photographers.Add(bidder as Photographer);
            }

            if (dto.BidderType == BidderType.DiscJockey)
            {
                bidder = new DiscJockey()
                {
                    Firstname = dto.Firstname,
                    Lastname = dto.Lastname,
                    Profile = profile,
                    Email = dto.Email,
                    CompanyName = dto.CompanyName
                };

                var gallery = new Gallery() { Name = "Profile" };
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_1.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_2.jpg" });
                gallery.Photos.Add(new Photo() { Url = "assets/images/carousel_3.jpg" });
                bidder.Galleries.Add(gallery);

                uow.DiscJockeys.Add(bidder as DiscJockey);
            }

            return bidder;
        }
 public IHttpActionResult TryToRegister(BidderRegistrationRequestDto dto)
     => Ok(this.service.TryToRegister(dto));