Example #1
0
        public ForgotPasswordResponseModel SendURL(string userName, string URL)
        {
            Guid id = Guid.NewGuid();

            bool   isSuccess = false;
            string message   = "";

            LogForgotPassword               temp          = new LogForgotPassword();
            ForgotPasswordResponseModel     responseModel = new ForgotPasswordResponseModel();
            ForgotPasswordMobileOutputModel outputModel   = new ForgotPasswordMobileOutputModel();

            UserRepository userRepo = new UserRepository(DbContext);

            var userInfo = userRepo.FindByUserName(userName);

            if (userInfo != null && userInfo.ID != null && userInfo.ID != Guid.Empty)
            {
                LogForgotPasswordRepository repo = new LogForgotPasswordRepository(DbContext);
                temp.ID             = id;
                temp.IsUsed         = false;
                temp.UserName       = userName;
                temp.DateRequest    = DateTime.Now;
                temp.DateExpired    = DateTime.Now.AddHours(3);
                temp.CreateByUserID = userInfo.ID;
                temp.CreateDate     = DateTime.Now;

                var result = repo.Insert(temp);

                if (result.Result)
                {
                    isSuccess = result.Result;
                    message   = result.Message;

                    outputModel.ID       = result.ID;
                    outputModel.UserName = userName;
                    outputModel.URL      = URL + result.ID.ToString();

                    responseModel.data = outputModel;
                }

                responseModel.Message  = message;
                responseModel.Response = isSuccess;
            }
            else
            {
                responseModel.Message  = "Can't find Username";
                responseModel.Response = false;
            }

            return(responseModel);
        }
        public Response Insert(LogForgotPassword data)
        {
            string   message = "Failed";
            bool     result  = false;
            Response res     = new Response();

            db.Add(data);
            db.SaveChanges();

            message = "Save data success";
            result  = true;

            res.ID      = data.ID;
            res.Message = message;
            res.Result  = result;

            return(res);
        }