示例#1
0
        public async Task <ActionResult> CheckPhoneRegister(string phone)
        {
            try
            {
                if (!_agencyDa.CheckExitsByPhone(phone, 0))
                {
                    var model = new DN_Agency
                    {
                        Phone      = phone,
                        IsActive   = false,
                        IsVerify   = false,
                        IsBank     = false,
                        IsFdi      = false,
                        IsDelete   = false,
                        CreateDate = DateTime.Now.TotalSeconds(),
                    };
                    _agencyDa.Add(model);
                    _agencyDa.Save();
                }
                //var otp = FDIUtils.RandomOtp(4);
                //var otppost = new PostOtpLoginAppIG4()
                //{
                //    msisdn = phone.Remove(0, 1).Insert(0, "84"),
                //    brandname = "G-STORE",
                //    msgbody = "IG4: Ma xac minh cua ban la " + otp,
                //    user = "******",
                //    pass = "******",
                //    charset = "8"
                //};
                //var url = "http://123.31.20.167:8383/restservice/";
                //var result = await PostDataAsync<List<ResultotpAppIG4>>(url, otppost);
                //if (result.FirstOrDefault()?.Result.code == "200")
                //{
                //    tokenOtpDA.Add(new TokenOtp()
                //    {
                //        ObjectId = phone,
                //        Token = otp,
                //        IsDeleted = false,
                //        IsUsed = false,
                //        TypeToken = (int)TokenOtpType.Authen,
                //        DateCreated = DateTime.Now,
                //    });
                //    tokenOtpDA.Save();
                //}
                //else
                //{
                //    return Json(new JsonMessage(-1, "Gửi mã OTP thất bại"), JsonRequestBehavior.AllowGet);
                //}
            }
            catch (Exception e)
            {
                return(Json(new JsonMessage(-2, e.ToString()), JsonRequestBehavior.AllowGet));
            }

            return(Json(new JsonMessage(200, "Ok"), JsonRequestBehavior.AllowGet));
        }
示例#2
0
 public ActionResult UpdateUser(string key, string username, int gender, string address, string birthday,
                                string fullname, string pass, string company, string depart, string mst, string stk, string bankname, string latitute, string longitude)
 {
     if (key != Keyapi)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
     try
     {
         var model = _da.GetByUsername(username);
         if (model != null)
         {
             model.Address         = address;
             model.Gender          = gender == 1;
             model.BirthDay        = ConvertUtil.ToDateTime(birthday).TotalSeconds();
             model.LoweredUserName = fullname;
             if (!string.IsNullOrEmpty(pass))
             {
                 var saltKey          = FDIUtils.CreateSaltKey(5);
                 var sha1PasswordHash = FDIUtils.CreatePasswordHash(pass, saltKey);
                 model.Password = sha1PasswordHash;
             }
             var agency = _agencyDa.GetById(model.AgencyID ?? 0);
             agency.Company    = company;
             agency.MST        = mst;
             agency.Department = depart;
             agency.STK        = stk;
             agency.BankName   = bankname;
             agency.Latitute   = latitute;
             agency.Longitude  = longitude;
             _agencyDa.Save();
             _da.Save();
             return(Json(1, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         return(Json(e.Message, JsonRequestBehavior.AllowGet));
     }
     return(Json(3, JsonRequestBehavior.AllowGet));
 }
示例#3
0
        public ActionResult Add(string key, string json)
        {
            var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công.");

            try
            {
                if (key == Keyapi)
                {
                    var date    = DateTime.Now.TotalSeconds();
                    var objitem = JsonConvert.DeserializeObject <AgencyItem>(json);
                    var obj     = new DN_Agency
                    {
                        IsDelete    = false,
                        IsLock      = false,
                        IsOut       = false,
                        CreateDate  = date,
                        WalletValue = 10000000,
                        CashOut     = 0,
                    };
                    obj = UpdateBase(obj, objitem);
                    _da.Add(obj);
                    _da.Save();
                    if (objitem.GroupID > 0)
                    {
                        _da.InsertDNModule(objitem.GroupID, obj.ID);
                    }
                    var saltKey          = FDIUtils.CreateSaltKey(5);
                    var sha1PasswordHash = FDIUtils.CreatePasswordHash(objitem.Pass, saltKey);
                    var user             = new DN_Users
                    {
                        UserId          = Guid.NewGuid(),
                        PasswordSalt    = saltKey,
                        Password        = sha1PasswordHash,
                        UserName        = objitem.UserName,
                        LoweredUserName = obj.Name,
                        Email           = obj.Email,
                        Address         = obj.Address,
                        AgencyID        = obj.ID,
                        Mobile          = obj.Phone,
                        IsApproved      = true,
                        IsLockedOut     = false,
                        CreateDate      = date,
                        IsDeleted       = false
                    };
                    _daUserDa.Add(user);
                    _daUserDa.Save();
                    var role = new DN_Roles {
                        RoleId = Guid.NewGuid(), RoleName = "Admin", LoweredRoleName = "admin", AgencyID = obj.ID, Description = "Quản trị"
                    };
                    _darRoleDa.Add(role);
                    var dnUsersInRoles = new DN_UsersInRoles
                    {
                        UserId      = user.UserId,
                        AgencyID    = obj.ID,
                        DateCreated = date,
                        IsDelete    = false
                    };
                    role.DN_UsersInRoles.Add(dnUsersInRoles);
                    _darRoleDa.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được thêm mới.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="mobile">UserName</param>
        /// <param name="mobile">SĐT3G</param>
        /// <param name="pass">Mật khẩu</param>
        /// <param name="address">Địa chỉ</param>
        /// <returns></returns>
        public ActionResult Addapp(string mobile, string pass, string address, string name, string email)
        {
            int gid  = 3;
            var objr = new DNUserAppItem
            {
                UserName      = mobile,
                EnterprisesID = 3,
                Status        = 0
            };

            try
            {
                if (string.IsNullOrEmpty(mobile))
                {
                    return(Json(new BaseResponse <AgencyItem>()
                    {
                        Erros = true, Message = "Số điện thoại không được để trống"
                    }));
                }
                if (string.IsNullOrEmpty(pass))
                {
                    return(Json(new BaseResponse <AgencyItem>()
                    {
                        Erros = true, Message = "Mật khẩu không được để trống"
                    }));
                }
                if (_daUserDa.CheckUserName(mobile, true))
                {
                    return(Json(new BaseResponse <AgencyItem>()
                    {
                        Erros = true, Message = "Số điện thoại đã tồn tại"
                    }));
                }

                var daten = DateTime.Now;
                var date  = daten.TotalSeconds();
                var obj   = new DN_Agency
                {
                    Address      = address,
                    FullName     = name,
                    Name         = mobile,
                    Phone        = mobile,
                    GroupID      = gid,
                    EnterpriseID = 3,
                    IsShow       = true,
                    IsDelete     = false,
                    IsLock       = false,
                    IsOut        = false,
                    IsFdi        = false,
                    CreateDate   = date,
                    WalletValue  = 0,
                    CashOut      = 0,
                    Email        = email
                };
                _da.Add(obj);
                _da.Save();
                if (obj.GroupID > 0)
                {
                    _da.InsertDNModule(obj.GroupID, obj.ID);
                }
                var saltKey          = FDIUtils.CreateSaltKey(5);
                var sha1PasswordHash = FDIUtils.CreatePasswordHash(pass, saltKey);
                var user             = new DN_Users
                {
                    UserId          = Guid.NewGuid(),
                    PasswordSalt    = saltKey,
                    Password        = sha1PasswordHash,
                    UserName        = mobile,
                    LoweredUserName = name,
                    Email           = pass,
                    Address         = address,
                    AgencyID        = obj.ID,
                    Mobile          = mobile,
                    IsApproved      = true,
                    IsLockedOut     = false,
                    CreateDate      = date,
                    IsDeleted       = false,
                    IsAgency        = true
                };
                _daUserDa.Add(user);
                _daUserDa.Save();
                var role = new DN_Roles {
                    RoleId = Guid.NewGuid(), RoleName = "Admin", LoweredRoleName = "admin", AgencyID = obj.ID, Description = "Quản trị"
                };
                _darRoleDa.Add(role);
                var dnUsersInRoles = new DN_UsersInRoles
                {
                    UserId      = user.UserId,
                    AgencyID    = obj.ID,
                    DateCreated = date,
                    IsDelete    = false
                };
                role.DN_UsersInRoles.Add(dnUsersInRoles);
                _darRoleDa.Save();

                var result = new BaseResponse <AgencyItem>()
                {
                    Erros = false,
                };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(new BaseResponse <AgencyItem>()
            {
                Erros = false
            }, JsonRequestBehavior.AllowGet));
        }