public async Task <Guid> Add(WorkshopAccountViewModel workshopViewModel, ApplicationUser user) { var workshopData = Mapper.Map <WorkshopData>(workshopViewModel); workshopData.UserID = user.Id; var workshopId = Guid.Empty; AnchorType anchor; using (var dbContext = _dbContextScope.Create()) { //check if the same instance is already exist: verify by NAME var gmapAddress = await geoLocator.DecodeAddress(workshopViewModel.Address.GooglePlaceId); var city = workshopData.Address?.City?.Ru; var country = ""; if (gmapAddress != null) { workshopData.Address = new AddressData { Building = gmapAddress.Number, GooglePlaceId = workshopViewModel.Address.GooglePlaceId, Street = gmapAddress.Street, }; city = gmapAddress.City; country = gmapAddress.Country; } workshopData.Address.CityID = VerifyOrAddCity(city, country); if (workshopData.IsPublished) { workshopData.IsPublished = false; } anchor = new AnchorType { Quantity = workshopData.AnchorNumber, Price = workshopData.PayHour, Name = "Hoist", Description = "For cars", }; workshopData.Anchors.Add(anchor); workshopData.Slug = HandleGenerator.Generate(12); workshopData.AccessCode = HandleGenerator.Generate(6); workshopId = _workshopAccountRepository.Add(workshopData); dbContext.SaveChanges(); } PublishWorkshopEvent <WorkshopCreated>(workshopData); if (anchor != null) { PublishAnchorCreated(workshopId, anchor); } await accountService.AddClaim(user, ApplicationClaims.Accomplished); return(workshopId); }