// get pharmacy merchant profile using id public async Task <PharmacyMerchantProfile> GetPharmacyMerchantProfile(int id) { PharmacyMerchantProfile pharmacyMerchantProfile = await _context.PharmacyMerchantProfiles. FirstOrDefaultAsync(x => x.Id == id); return(pharmacyMerchantProfile); }
public async Task <IActionResult> UpdatePharmacyMerchantProfile(int id, PharmacyMerchantProfile pharmacyMerchant) { ServiceResponse <string> updateProfileResponse = await _merchantProfileRepo.UpdatePharmacyMerchantProfile(id, pharmacyMerchant); if (!updateProfileResponse.Success) { return(BadRequest()); } return(Ok(updateProfileResponse)); }
// update pharmacy merchant profile public async Task <ServiceResponse <string> > UpdatePharmacyMerchantProfile(int id, PharmacyMerchantProfile pharmacyMerchantProfile) { ServiceResponse <string> response = new ServiceResponse <string>(); var pharmacymerchantprofile = await _context.PharmacyMerchantProfiles.FirstOrDefaultAsync(x => x.Id == id); if (pharmacymerchantprofile != null) { pharmacymerchantprofile.FirstName = pharmacyMerchantProfile.FirstName; pharmacymerchantprofile.LastName = pharmacyMerchantProfile.LastName; pharmacymerchantprofile.Phone = pharmacyMerchantProfile.Phone; pharmacymerchantprofile.Email = pharmacyMerchantProfile.Email; pharmacymerchantprofile.Address = pharmacyMerchantProfile.Address; pharmacymerchantprofile.MerchantPaymentType = pharmacyMerchantProfile.MerchantPaymentType; pharmacymerchantprofile.PaymentPeriod = pharmacyMerchantProfile.PaymentPeriod; pharmacymerchantprofile.PharmacyName = pharmacyMerchantProfile.PharmacyName; pharmacymerchantprofile.DrugLicenseNumber = pharmacyMerchantProfile.DrugLicenseNumber; pharmacymerchantprofile.TradeLicenseNumber = pharmacyMerchantProfile.TradeLicenseNumber; pharmacymerchantprofile.NidNumber = pharmacyMerchantProfile.NidNumber; pharmacymerchantprofile.PharmacyRatting = pharmacyMerchantProfile.PharmacyRatting; pharmacymerchantprofile.CreationDate = pharmacyMerchantProfile.CreationDate; pharmacymerchantprofile.ApprovedDate = pharmacyMerchantProfile.ApprovedDate; pharmacymerchantprofile.BlockDate = pharmacyMerchantProfile.BlockDate; pharmacymerchantprofile.SuspendedDate = pharmacyMerchantProfile.SuspendedDate; pharmacymerchantprofile.LoginStatus = pharmacyMerchantProfile.LoginStatus; pharmacymerchantprofile.PharmacyMerchantId = pharmacyMerchantProfile.PharmacyMerchantId; _context.PharmacyMerchantProfiles.Update(pharmacymerchantprofile); await _context.SaveChangesAsync(); response.Message = "Profile data updated successfully"; } else { response.Success = false; response.Message = "No profile created for merchant!"; } return(response); }
// create pharmacy merchant profile public async Task <ServiceResponse <PharmacyMerchantProfileDto> > CreatePharmacyMerchantProfile(PharmacyMerchantProfileDto pharmacyMerchantProfileDto) { ServiceResponse <PharmacyMerchantProfileDto> response = new ServiceResponse <PharmacyMerchantProfileDto>() { Data = new PharmacyMerchantProfileDto() }; MerchantPharmacy pharmacyMerchant = await _context.MerchantPharmacys.FirstOrDefaultAsync(x => x.Email == pharmacyMerchantProfileDto.Email.ToLower()); if (pharmacyMerchant != null) { var pharmacyMerchantProfile = new PharmacyMerchantProfile() { FirstName = pharmacyMerchantProfileDto.FirstName, LastName = pharmacyMerchantProfileDto.LastName, Phone = pharmacyMerchantProfileDto.Phone, Email = pharmacyMerchantProfileDto.Email, Address = pharmacyMerchantProfileDto.Address, MerchantPaymentType = pharmacyMerchantProfileDto.MerchantPaymentType, PaymentPeriod = pharmacyMerchantProfileDto.PaymentPeriod, PharmacyName = pharmacyMerchantProfileDto.PharmacyName, DrugLicenseNumber = pharmacyMerchantProfileDto.DrugLicenseNumber, TradeLicenseNumber = pharmacyMerchantProfileDto.TradeLicenseNumber, NidNumber = pharmacyMerchantProfileDto.NidNumber, CreationDate = pharmacyMerchant.CreatedAt, ApprovedDate = DateTime.UtcNow, LoginStatus = pharmacyMerchantProfileDto.LoginStatus, PharmacyMerchantId = pharmacyMerchant.Id }; await _context.PharmacyMerchantProfiles.AddAsync(pharmacyMerchantProfile); await _context.SaveChangesAsync(); response.Data = new PharmacyMerchantProfileDto { FirstName = pharmacyMerchantProfile.FirstName, LastName = pharmacyMerchantProfile.LastName, Phone = pharmacyMerchantProfile.Phone, Email = pharmacyMerchantProfile.Email, Address = pharmacyMerchantProfile.Address, MerchantPaymentType = pharmacyMerchantProfile.MerchantPaymentType, PaymentPeriod = pharmacyMerchantProfile.PaymentPeriod, PharmacyName = pharmacyMerchantProfile.PharmacyName, DrugLicenseNumber = pharmacyMerchantProfile.DrugLicenseNumber, TradeLicenseNumber = pharmacyMerchantProfile.TradeLicenseNumber, NidNumber = pharmacyMerchantProfile.NidNumber, ApprovedDate = pharmacyMerchantProfile.ApprovedDate, LoginStatus = pharmacyMerchantProfile.LoginStatus, PharmacyMerchantId = pharmacyMerchantProfile.Id }; response.Message = "Pharmacy merchant profile created successfully!"; } else { response.Success = false; response.Data = new PharmacyMerchantProfileDto { }; response.Message = "Pharmacy merchant profile create failed!"; } return(response); }