コード例 #1
0
ファイル: DAL_Login.cs プロジェクト: farishadyann/Store
        public bool RegisterNewAccount(MS_UserInfo_Request req)
        {
            bool Retval;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                try
                {
                    List <SqlParameter> Parameter = new List <SqlParameter>();

                    //param
                    //Parameter.Add(new SqlParameter() { ParameterName = "@pPostType", SqlDbType = SqlDbType.VarChar, Value = req.PostType.ToString() ?? "" });
                    Parameter.Add(new SqlParameter()
                    {
                        ParameterName = "@pEmail", SqlDbType = SqlDbType.VarChar, Value = req.Email ?? ""
                    });
                    Parameter.Add(new SqlParameter()
                    {
                        ParameterName = "@pUserName", SqlDbType = SqlDbType.VarChar, Value = req.UserName ?? ""
                    });
                    Parameter.Add(new SqlParameter()
                    {
                        ParameterName = "@pPassword", SqlDbType = SqlDbType.VarChar, Value = req.Password ?? ""
                    });
                    Parameter.Add(new SqlParameter()
                    {
                        ParameterName = "@pCreatedDate", SqlDbType = SqlDbType.DateTime, Value = req.CreatedDate.HasValue ? req.CreatedDate : DateTime.Today
                    });

                    DBtran.DbExecute("USP_REGISTER_USER", Parameter, true, out SqlParameterCollection outParameter);

                    transactionScope.Complete();

                    Retval = true;
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();

                    throw new Exception("DAL error : " + ex.Message);
                }
            }

            return(Retval);
        }
コード例 #2
0
        public List <MS_UserInfo_Response> RegistrasiCek(MS_UserInfo_Request req)
        {
            List <MS_UserInfo_Response> retVal = new List <MS_UserInfo_Response>();

            try
            {
                retVal = DAL.RegistrasiCek(req);
            }
            catch (Exception ex)
            {
                retVal = null;
                throw ex;
            }
            finally
            {
            }
            return(retVal);
        }
コード例 #3
0
ファイル: DAL_Login.cs プロジェクト: farishadyann/Store
        public List <MS_UserInfo_Response> RegistrasiCek(MS_UserInfo_Request req)
        {
            List <MS_UserInfo_Response> RetVal = new List <MS_UserInfo_Response>();

            try
            {
                DataTable dt = DBtran.DbToDataTable("[dbo].[USP_GET_REGISTRASI_CEK]", new
                {
                    pUserName = req.UserName,
                    pEmail    = req.Email
                }, true);

                foreach (DataRow row in dt.Rows)
                {
                    RetVal.Add(new MS_UserInfo_Response
                    {
                        UserInfoID_PK   = string.IsNullOrEmpty(row["UserInfoID_PK"].ToString())? 0 :Convert.ToInt32(row["UserInfoID_PK"]),
                        UserID_FK       = string.IsNullOrEmpty(row["UserID_FK"].ToString()) ? 0 : Convert.ToInt32(row["UserID_FK"]),
                        UserName        = string.IsNullOrEmpty(row["UserName"].ToString()) ? "" : row["UserName"].ToString(),
                        Email           = string.IsNullOrEmpty(row["Email"].ToString()) ? "" : row["Email"].ToString(),
                        BornDate        = string.IsNullOrEmpty(row["BornDate"].ToString()) ? DateTime.Now : Convert.ToDateTime(row["BornDate"]),
                        IsActive        = string.IsNullOrEmpty(row["IsActive"].ToString()) ? false : Convert.ToBoolean(row["IsActive"]),
                        IsDelete        = string.IsNullOrEmpty(row["IsDelete"].ToString()) ? false : Convert.ToBoolean(row["IsDelete"]),
                        FullName        = string.IsNullOrEmpty(row["FullName"].ToString()) ? "" : row["FullName"].ToString(),
                        CreatedBy       = string.IsNullOrEmpty(row["CreatedBy"].ToString()) ? "" : row["CreatedBy"].ToString(),
                        CreatedDate     = string.IsNullOrEmpty(row["CreatedDate"].ToString()) ? DateTime.Now : Convert.ToDateTime(row["CreatedDate"]),
                        ModifiedBy      = string.IsNullOrEmpty(row["ModifiedBy"].ToString()) ? "" : row["ModifiedBy"].ToString(),
                        ModifiedDate    = string.IsNullOrEmpty(row["ModifiedDate"].ToString()) ? DateTime.Now : Convert.ToDateTime(row["ModifiedDate"]),
                        ResponseAction  = string.IsNullOrEmpty(row["IsExists"].ToString()) ? false : Convert.ToBoolean(row["IsExists"]),
                        ResponseMessage = string.IsNullOrEmpty(row["ResponseMessage"].ToString()) ? "" : row["ResponseMessage"].ToString(),
                    });
                }
            }
            catch (Exception ex)
            {
                RetVal = null;
                throw ex;
            }
            finally
            {
            }
            return(RetVal);
        }
コード例 #4
0
        public ActionResult Register(MS_UserInfo_Request req)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    List <MS_UserInfo_Response> Cek = BL.RegistrasiCek(req);
                    bool IsExists = Convert.ToBoolean(Cek.FirstOrDefault().ResponseAction);
                    if (!IsExists)
                    {
                        bool Req = BL.RegisterNewAccount(req);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.Error = Cek.FirstOrDefault().ResponseMessage.ToString();
                        ViewBag.Err   = "Y";
                        return(View("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                MS_ActivityLog param = new MS_ActivityLog
                {
                    ActionName     = ControllerContext.RouteData.Values["action"].ToString(),
                    UserID_FK      = 0,
                    ControllerName = ControllerContext.RouteData.Values["controller"].ToString(),
                    Description    = ex.Message.ToString(),
                    ActivityDate   = DateTime.Now
                };
                bool RetVal = Act.ActivityLog(param);
            }

            return(View());
        }
コード例 #5
0
        public bool RegisterNewAccount(MS_UserInfo_Request req)
        {
            bool Retval = DAL.RegisterNewAccount(req);

            return(Retval);
        }