public async Task <IActionResult> CreateRestaurantMerchantProfile(RestaurantMerchantProfileDto restaurantMerchantProfile) { ServiceResponse <RestaurantMerchantProfileDto> merchantProfileResponse = await _merchantProfileRepository.CreateRestaurantMerchantProfile(restaurantMerchantProfile); if (!merchantProfileResponse.Success) { return(BadRequest(merchantProfileResponse)); } return(Ok(merchantProfileResponse)); }
// create restaurant merchant profile public async Task <ServiceResponse <RestaurantMerchantProfileDto> > CreateRestaurantMerchantProfile(RestaurantMerchantProfileDto restaurantMerchantProfileDto) { ServiceResponse <RestaurantMerchantProfileDto> response = new ServiceResponse <RestaurantMerchantProfileDto>() { Data = new RestaurantMerchantProfileDto() }; MerchantRestaurant restaurantMerchant = await _context.MerchantRestaurants.FirstOrDefaultAsync(x => x.Email == restaurantMerchantProfileDto.Email.ToLower()); if (restaurantMerchant != null) { var restaurantMerchantProfile = new RestaurantMerchantProfile() { FirstName = restaurantMerchantProfileDto.FirstName, LastName = restaurantMerchantProfileDto.LastName, Phone = restaurantMerchantProfileDto.Phone, Email = restaurantMerchantProfileDto.Email, Address = restaurantMerchantProfileDto.Address, MerchantPaymentType = restaurantMerchantProfileDto.MerchantPaymentType, PaymentPeriod = restaurantMerchantProfileDto.PaymentPeriod, RestaurantName = restaurantMerchantProfileDto.RestaurantName, TradeLicenseNumber = restaurantMerchantProfileDto.TradeLicenseNumber, NidNumber = restaurantMerchantProfileDto.NidNumber, CreationDate = restaurantMerchant.CreatedAt, ApprovedDate = DateTime.UtcNow, LoginStatus = restaurantMerchantProfileDto.LoginStatus, RestaurantMerchantId = restaurantMerchant.Id }; await _context.RestaurantMerchantProfiles.AddAsync(restaurantMerchantProfile); await _context.SaveChangesAsync(); response.Data = new RestaurantMerchantProfileDto { FirstName = restaurantMerchantProfile.FirstName, LastName = restaurantMerchantProfile.LastName, Phone = restaurantMerchantProfile.Phone, Email = restaurantMerchantProfile.Email, Address = restaurantMerchantProfile.Address, MerchantPaymentType = restaurantMerchantProfile.MerchantPaymentType, PaymentPeriod = restaurantMerchantProfile.PaymentPeriod, RestaurantName = restaurantMerchantProfile.RestaurantName, TradeLicenseNumber = restaurantMerchantProfile.TradeLicenseNumber, NidNumber = restaurantMerchantProfile.NidNumber, ApprovedDate = restaurantMerchantProfile.ApprovedDate, LoginStatus = restaurantMerchantProfile.LoginStatus, RestaurantMerchantId = restaurantMerchantProfile.Id }; response.Message = "Restaurant merchant profile created successfully!"; } else { response.Success = false; response.Data = new RestaurantMerchantProfileDto { }; response.Message = "Restaurant merchant profile create failed!"; } return(response); }