public BaseModel ForgotPassword(string emailAddress) { BaseModel statusModel = new BaseModel(); try { Worker worker = FindByEmailAddress(emailAddress); if (worker != null) { EmailTemplateRepository emailTemplateRepository = new EmailTemplateRepository(context); EmailTemplate emailTemplate = emailTemplateRepository.FindByEmailTemplateCategoryID(1); emailTemplateRepository.Remove(emailTemplate); if (emailTemplate != null) { EmailManager emailManager = new EmailManager(this); statusModel = emailManager.BuildAndSendEmail(emailTemplate, worker); } else { throw new CustomException(CustomExceptionType.CommonCriticalDataNotFound, "Email template not found"); } } else { throw new CustomException(CustomExceptionType.CommonCriticalDataNotFound, "We don't find any record using the email address"); } } catch (CustomException ex) { statusModel.ErrorMessage = ex.UserDefinedMessage; } catch { statusModel.ErrorMessage = Constants.Messages.UnhandelledError; } return(statusModel); }