// 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); }
public async Task <IActionResult> UpdateRestaurantMerchantProfile(int id, RestaurantMerchantProfile restaurantMerchantProfile) { ServiceResponse <string> updateProfileResponse = await _merchantProfileRepository.UpdateRestaurantMerchantProfile(id, restaurantMerchantProfile); if (!updateProfileResponse.Success) { return(BadRequest(updateProfileResponse)); } return(Ok(updateProfileResponse)); }
//update restaurant merchant profile public async Task <ServiceResponse <string> > UpdateRestaurantMerchantProfile(int id, RestaurantMerchantProfile restaurantMerchantProfile) { ServiceResponse <string> response = new ServiceResponse <string>(); var restaurantmerchantprofile = await _context.RestaurantMerchantProfiles.FirstOrDefaultAsync(x => x.Id == id); if (restaurantmerchantprofile != null) { restaurantmerchantprofile.FirstName = restaurantMerchantProfile.FirstName; restaurantmerchantprofile.LastName = restaurantMerchantProfile.LastName; restaurantmerchantprofile.Phone = restaurantMerchantProfile.Phone; restaurantmerchantprofile.Email = restaurantMerchantProfile.Email; restaurantmerchantprofile.Address = restaurantMerchantProfile.Address; restaurantmerchantprofile.MerchantPaymentType = restaurantMerchantProfile.MerchantPaymentType; restaurantmerchantprofile.PaymentPeriod = restaurantMerchantProfile.PaymentPeriod; restaurantmerchantprofile.RestaurantName = restaurantMerchantProfile.RestaurantName; restaurantmerchantprofile.TradeLicenseNumber = restaurantMerchantProfile.TradeLicenseNumber; restaurantmerchantprofile.NidNumber = restaurantMerchantProfile.NidNumber; restaurantmerchantprofile.RestaurantRatting = restaurantMerchantProfile.RestaurantRatting; restaurantmerchantprofile.CreationDate = restaurantMerchantProfile.CreationDate; restaurantmerchantprofile.ApprovedDate = restaurantMerchantProfile.ApprovedDate; restaurantmerchantprofile.BlockDate = restaurantMerchantProfile.BlockDate; restaurantmerchantprofile.SuspendedDate = restaurantMerchantProfile.SuspendedDate; restaurantmerchantprofile.LoginStatus = restaurantMerchantProfile.LoginStatus; restaurantmerchantprofile.RestaurantMerchantId = restaurantMerchantProfile.RestaurantMerchantId; _context.RestaurantMerchantProfiles.Update(restaurantmerchantprofile); await _context.SaveChangesAsync(); response.Message = "Profile data updated successfully"; } else { response.Success = false; response.Message = "No profile created for merchant!"; } return(response); }
// get restaurant merchant profile using id public async Task <RestaurantMerchantProfile> GetRestaurantMerchantProfile(int id) { RestaurantMerchantProfile restaurantMerchantProfile = await _context.RestaurantMerchantProfiles.FirstOrDefaultAsync(x => x.Id == id); return(restaurantMerchantProfile); }