//private ICollection<PictureViewModel> pictures; public GuestEscortDetailViewModel(Escort escort) : base(escort) { this.Description = escort.Description == null ? "--" : escort.Description; this.Town = escort.Town; this.Pictures = escort.Pictures.Select(p => p.B64).ToArray(); var prices = escort.Prices; if (prices == null) this.HourRate = "--"; else this.HourRate = prices.HourRate.ToString(); }
public GuestEscortViewModel(Escort escort) { this.UserName = escort.UserName; this.Gender = escort.Gender.ToString(); this.B64Profile = escort.Pictures.FirstOrDefault(p => p.IsProfile == true).B64; }
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(); }