public PriceListViewModel(PriceList priceList)
 {
     this.EscortName = priceList.Escort.UserName;
     this.ThirtyMinuteRate = priceList.ThirtyMinuteRate;
     this.HourRate = priceList.HourRate;
     this.ThreeHoursRate = priceList.ThreeHoursRate;
     this.SixHoursRate = priceList.SixHoursRate;
     this.OvernightRate = priceList.OvernightRate;
     this.DailyRate = priceList.DailyRate;
     this.WeekendRate = priceList.WeekendRate;
     this.WeeklyRate = priceList.WeeklyRate;
 }
        public async Task<IHttpActionResult> RegisterEscort(RegisterEscortBindingModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var user = new Escort()
            {
                UserName = model.Username,
                Email = model.Email,
                PhoneNumber = model.PhoneNumber,
                Gender = (Gender)Enum.Parse(typeof(Gender), model.Gender, true),
                Town = model.Town,
                Height = model.Height,
                Weight = model.Weight,
                BreastsType = (BreastsType)Enum.Parse(typeof(BreastsType), model.BreastsType, true),
                Description = model.Description,
                HairColour = model.HairColour,
                IsDeleted = false,
                AddressOfService = model.AddressOfService
            };

            IdentityResult result = await this.UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return this.GetErrorResult(result);
            }
            var newUser = this.EscortServiceData.Users.FirstOrDefault(u => u.UserName == user.UserName);
            if (newUser != null)
            {
                var roleUser = this.UserManager.AddToRole(newUser.Id, "escort");

                if (model.B64 != null)
                {
                    var newPicture = new Picture()
                    {
                        EscortId = newUser.Id,
                        B64 = model.B64,
                        IsProfile = true
                    };

                    this.EscortServiceData.Pictures.Add(newPicture);
                }

                var priceList = this.EscortServiceData.PriceLists
               .FirstOrDefault(p => p.EscortId == newUser.Id);

                if (priceList == null)
                {
                    var newPriceList = new PriceList
                    {
                        EscortId = newUser.Id,
                        ThirtyMinuteRate = null,
                        HourRate = null,
                        ThreeHoursRate = null,
                        SixHoursRate = null,
                        OvernightRate = null,
                        DailyRate = null,
                        WeekendRate = null,
                        WeeklyRate = null
                    };

                    this.EscortServiceData.PriceLists.Add(newPriceList);
                }

                this.EscortServiceData.SaveChanges();
            }

            //Auto login after registration (successful user registration should return access_token)
            //var loginResult = await this.LoginUser(new UserAccountInputModel()
            //{
            //    Username = model.Username,
            //    Password = model.Password
            //});

            //return loginResult;
            return this.Ok();
        }