Example #1
0
        public JsonResult UpdUserInfo(string UserId, Dictionary <int, byte?> demandLevelInfoList)
        {
            using (ResponseResult <object> result = new ResponseResult <object>())
            {
                //2017-1-17修改UserId类型,
                var    userInfo = _userService.GetByKey(Convert.ToInt32(UserId));
                T_USER model    = new T_USER()
                {
                    Id          = Convert.ToInt64(Request.Form["Id"]),
                    UserName    = Request.Form["UserName"].ToString(),
                    PhoneNumber = userInfo.PhoneNumber,
                    DPoint      = string.IsNullOrEmpty(Request.Form["DPoint"]) ? null : (int?)Convert.ToInt32(Request.Form["DPoint"]),
                    Province    = Request.Form["Province"].ToString(),
                    City        = Request.Form["City"].ToString(),
                    Region      = Request.Form["Region"].ToString(),
                    Township    = Request.Form["Township"].ToString(),
                    Village     = Request.Form["Village"].ToString()
                };
                if (!string.IsNullOrEmpty(UserId))
                {
                    this._userService.UpdateUserInfo(model, demandLevelInfoList, Convert.ToInt64(UserId));
                    result.IsSuccess = true;
                    result.Message   = ResponeString.UpdateOK;
                    result.Entity    = 1;
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = ResponeString.NotLogin;
                }

                return(new JsonResultEx(result));
            }
        }
Example #2
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isdelete"></param>
        /// <returns></returns>
        public ActionResult DeleUser(int id)
        {
            T_USER user = userManageService.GetUserByKey(Convert.ToInt32(id));

            user.IS_USE      = 0;
            user.CREATE_TIME = DateTime.Now;
            userManageService.DeleUser(user);
            /// usersService.DeleUser(key);
            return(RedirectToAction("Index"));
        }
Example #3
0
        public void AddUser(UserEntity user)
        {
            var newUser = new T_USER();

            newUser.EMP_ID      = user.EmployeeId;
            newUser.EMP_FRST_NM = user.FirstName;
            newUser.EMP_LST_NM  = user.LastName;

            _db.T_USER.Add(newUser);
            _db.SaveChanges();
        }
Example #4
0
        /// <summary>
        ///删除用户
        /// </summary>
        public void DeleUser(T_USER newuser)
        {
            T_USER user = db.T_USER.Find(newuser.USER_ID);

            if (user != null)
            {
                db.T_USER.Attach(newuser);
                db.Entry(newuser).State = EntityState.Modified;   //直接修改数据库上下文
                db.SaveChanges();
                //删除多条数据参照查找
            }
        }
Example #5
0
        /// <summary>
        /// 通过id  来改变用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult ChangeUser(string userId, string userName, string nickname, string passWord, string userType)
        {
            T_USER user = userManageService.GetUserByKey(Convert.ToInt32(userId));

            user.USER_NAME   = userName;
            user.LOGIN_NAME  = nickname;
            user.PASSWORD    = passWord;
            user.USER_TYPE   = Convert.ToInt32(userType);
            user.IS_USE      = 1;
            user.CREATE_TIME = DateTime.Now;
            userManageService.ChangeUser(user);
            return(RedirectToAction("Index"));
        }
Example #6
0
 public ActionResult Edit(T_USER Usuario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(Usuario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
        /// <summary>
        /// Get user by User ID
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public Model.ViewModel.User GetUser(int UserId)
        {
            T_USER UserEntity = GetUserById(UserId);

            if (UserEntity != null)
            {
                return(UMapper.MapToView(UserEntity));
            }
            else
            {
                throw new UserNotFoundException();
            }
        }
 public IHttpActionResult Put([FromUri] T_USER Usuarios)
 {
     if (ModelState.IsValid)
     {
         db.Entry(Usuarios).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { Resultado = "Registro Actualizado" }));
     }
     else
     {
         return(Json(new { Resultado = "Error, Los datos no concuerdan" }));
     }
 }
Example #9
0
 public ActionResult Create(T_USER Usuario)
 {
     if (ModelState.IsValid)
     {
         db.T_USER.Add(Usuario);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
        //[Route("api/FirstExam/busqueda/{id}")]
        //[HttpGet]
        //public IHttpActionResult Busqueda(int ID, string NombreConsulta) {

        //    var UsuarioBusqueda = db.T_USER.Where(w => w.CODIGO == ID).FirstOrDefault();
        //    int[] grupo = new int[] {5,2,3,7,8};


        //    return Json(UsuarioBusqueda);
        //}

        public IHttpActionResult Post([FromUri] T_USER Usuarios)
        {
            if (ModelState.IsValid)
            {
                db.T_USER.Add(Usuarios);
                db.SaveChanges();
                return(Json(new { Resultado = "Registro guardado" }));
            }
            else
            {
                return(Json(new { Resultado = "Error, Los datos no concuerdan" }));
            }
        }
        public void ToEntityTest()
        {
            T_USER UserEntity = new T_USER
            {
                OID        = 0,
                NAME       = "Juan",
                BIRTH_DATE = DateTime.Now,
            };
            User UserView = new UserMapper().MapToView(UserEntity);

            Assert.AreEqual(UserEntity.OID, UserView.Id);
            Assert.AreEqual(UserEntity.NAME, UserView.Name);
            Assert.AreEqual(UserEntity.BIRTH_DATE, UserView.BirthDate);
        }
        /// <summary>
        /// Delete User specified by User ID
        /// </summary>
        /// <param name="UserId"></param>
        public void DeleteUser(int UserId)
        {
            T_USER UserEntity = GetUserById(UserId);

            if (UserEntity != null)
            {
                Db.T_USER.Remove(UserEntity);
                Db.SaveChanges();
            }
            else
            {
                throw new UserNotFoundException();
            }
        }
 /// <summary>
 /// Modify User
 /// </summary>
 /// <param name="User"></param>
 public void ModifyUser(Model.ViewModel.User User)
 {
     if (UserIdExists(User.Id))
     {
         T_USER NewUserEntity = UMapper.MapToEntity(User);
         Db.Attach(NewUserEntity);
         Db.Entry(NewUserEntity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         Db.SaveChanges();
     }
     else
     {
         throw new UserNotFoundException();
     }
 }
Example #14
0
        public ActionResult AddUser(string userName, string nickName, string passWord, string userType)
        {
            //实例一个文件
            T_USER user = new T_USER();

            user.USER_NAME  = userName;
            user.LOGIN_NAME = nickName;
            user.PASSWORD   = passWord;
            user.USER_TYPE  = Convert.ToInt32(userType);
            user.IS_USE     = 0;

            user.CREATE_TIME = DateTime.Now;
            userManageService.AddUser(user);
            return(RedirectToAction("Index"));   //重定向
        }
        /// <summary>
        /// Add new user to database
        /// </summary>
        /// <param name="User"></param>
        public void AddUser(Model.ViewModel.User User)
        {
            T_USER UserEntity = UMapper.MapToEntity(User);

            if (!UserNameExists(UserEntity.NAME))
            {
                //Set Id to zero because database is set to autoincrement
                UserEntity.OID = 0;
                Db.T_USER.Add(UserEntity);
                Db.SaveChanges();
            }
            else
            {
                throw new UserAlreadyExistsException();
            }
        }
Example #16
0
        public ActionResult UpdUserInfo(T_USER model, Dictionary <int, byte?> demandLevelInfoList)
        {
            var postParas = new Dictionary <string, string>();

            //postParas.Add("UserId", GetLoginInfo().User.Id.ToString());
            postParas.Add("UserId", model.Id.ToString());
            Dictionary <string, string> usermodel = Utility.ModelHelper.GetPropertyDictionary <T_USER>(model);

            foreach (var item in usermodel)
            {
                postParas.Add(item.Key, item.Value);
            }
            for (var item = 0; item < demandLevelInfoList.Count; item++)
            {
                var tempItem = demandLevelInfoList.ElementAt(item);
                postParas.Add("demandLevelInfoList[" + item + "].Key", tempItem.Key.ToString());
                postParas.Add("demandLevelInfoList[" + item + "].Value", tempItem.Value.ToString());
            }
            //证书的路径
            var certification = GetCertificationFilePath();
            //证书的密码
            var certificationPwd = GetCertificationPwd();

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseString = HttpAsynchronousTool.CustomHttpWebRequestPost(GetCurrentUrl(this), postParas, certification, certificationPwd);
            var responseObj    = JsonHelper.FromJsonTo <ResponseResult <object> >(responseString);

            if (responseObj.IsSuccess == true)
            {
                TempData["Message"] = "修改成功!";
                return(RedirectToAction("List"));
            }
            else
            {
                ModelState.AddModelError("", responseObj.Message);
                return(View("GetUpdData"));
            }
        }
Example #17
0
        public UserInfo(int userID)
        {
            if (this.ID != userID)
            {
                this.ID = userID;
                if (userID != AnonymousUser)
                {
                    var user = T_USER.SelectExact(userID);
                    if (user != null)
                    {
                        this.Role          = user.UserRole;
                        this.FullName      = user.FullName;
                        this.CompanyID     = user.CompanyID;
                        this.PanelDoctorID = user.PanelDoctorID;
                    }
                }

                if (string.IsNullOrEmpty(this.FullName))
                {
                    this.FullName = "Visitor";
                }
            }
        }
Example #18
0
        public JsonResult userLogin(string userName, string psw)
        {
            T_USER user = userManageService.login(userName, psw);
            Dictionary <string, object> res = new Dictionary <string, object>();

            if (user == null)
            {
                res.Add("success", 0);
                res.Add("msg", "账号或密码错误!");
            }
            else if (user.IS_USE == 0)
            {
                res.Add("success", 0);
                res.Add("msg", "账号未启用!");
            }
            else
            {
                Session["loginName"] = user.LOGIN_NAME;
                res.Add("success", 1);
                res.Add("msg", "登陆成功!");
            }
            return(Json(res));
        }
Example #19
0
        public bool UpdateUserAndThirdParty(T_USER user, string thirdPartyId, string from)
        {
            bool isSucess = true;

            using (var tran = DbContext.DbTransaction)
            {
                try
                {
                    DbContext.Update(user);

                    var thirdPartyEntity = new T_THIRD_PARTY();
                    thirdPartyEntity.U_USER_ID        = user.ID;
                    thirdPartyEntity.T_THIRD_PARTY_ID = thirdPartyId;
                    thirdPartyEntity.T_FROM           = from;
                    thirdPartyEntity.CREATE_TIME      = DateTime.Now;
                    DbContext.Insert(thirdPartyEntity);
                }
                catch (Exception e)
                {
                    isSucess = false;
                    throw e;
                }
                finally
                {
                    if (isSucess)
                    {
                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }
                return(isSucess);
            }
        }
Example #20
0
 /// <summary>
 ///增加用户
 /// </summary>
 public void AddUser(T_USER user)
 {
     db.T_USER.Add(user); //直接在数据库上下文的表添加数据
     db.SaveChanges();    //可以同时添加多条数据,直接在最后SaveChanges保存就行,返回值为影响的行数
 }
Example #21
0
        public JsonResult ReplyFarmerRequirement(long id, string userId, string Name, string NickName, string Address, string PhoneNum, string OtherMachinery, int Credit, int SourceType = 1)
        {
            using (ResponseResult <T_FARMER_DEMAND_RESPONSE_RELATION> result = new ResponseResult <T_FARMER_DEMAND_RESPONSE_RELATION>())
            {
                //e田农机手,在先锋帮的用户id
                long UserId = 0;
                T_FARMER_PUBLISHED_DEMAND firstmodel = _commonRepository.GetById <T_FARMER_PUBLISHED_DEMAND>(f => f.Id == id);
                //验证需求是否存在于大农户需求表中
                if (firstmodel != null)
                {
                    #region 保存农机手数据

                    List <T_USER> list = _userRepository.GetAll(c => c.WeatherCity == userId).ToList();
                    if (list.Count() > 0)
                    {
                        UserId = list[0].Id;
                    }
                    else
                    {
                        var user = new T_USER
                        {
                            PhoneNumber       = PhoneNum,
                            Password          = Encrypt.MD5Encrypt("111"),
                            CreateTime        = DateTime.Now,
                            IsDeleted         = false,
                            LoginUserName     = PhoneNum,
                            LastLoginTime     = DateTime.Now,
                            LastUpdatePwdTime = DateTime.Now,
                            SourceType        = SourceType,
                            WeatherCity       = userId//因为e田的农机手不登录,所以用本字段
                        };
                        int rows = _userRepository.Insert(user);
                        //构建农机手角色申请信息实体
                        var entity = new T_MACHINERY_OPERATOR_VERIFICATION_INFO()
                        {
                            UserId     = user.Id,
                            CreateTime = DateTime.Now,
                            AuditState = 0,
                            Machinery  = "[]",//必须有内容,否则后台getUpddata方法会报错
                            OtherMachineDescription = OtherMachinery,
                            RealName    = Name,
                            PhoneNumber = PhoneNum
                        };
                        _operatorRepository.Insert(entity);

                        var userRoleDemandTypeLevelMapping = new Dictionary <int, int> {
                            { 1, 1 }
                        };

                        var verificationSuccess = this._roleVerificationRepository.ApproveOperatorVerification(entity.Id, user.Id, userRoleDemandTypeLevelMapping);
                        UserId = user.Id;//农机手id
                    }


                    #endregion
                    //验证是否是发布给农机手的需求
                    if (_commonRepository.CheckTypeid <T_SYS_DICTIONARY>(s => s.Code == firstmodel.DemandTypeId && s.ParentCode == 100100))
                    {
                        //验证userid是否是农机手id
                        if (_commonRepository.CheckUserId(UserId, (int)RoleType.MachineryOperator))
                        {
                            //验证需求为待响应
                            if (firstmodel.PublishStateId == 100501)
                            {
                                //验证当前用户是否接受过此订单
                                if (!_commonRepository.CheckTypeid <T_FARMER_DEMAND_RESPONSE_RELATION>(f => f.DemandId == id && f.UserId == UserId))
                                {
                                    T_FARMER_DEMAND_RESPONSE_RELATION model = new T_FARMER_DEMAND_RESPONSE_RELATION()
                                    {
                                        DemandId   = id,
                                        UserId     = UserId,
                                        CreateTime = Utility.TimeHelper.GetChinaLocalTime(),
                                        ReplyTime  = Utility.TimeHelper.GetChinaLocalTime(),
                                        //增加新增字段ww
                                        ReplyTimeFarmer = Utility.TimeHelper.GetChinaLocalTime(),
                                        //1 E田的农机手
                                        SourceType = 1
                                    };
                                    //添加响应记录
                                    _commonRepository.Add <T_FARMER_DEMAND_RESPONSE_RELATION>(model);
                                    //响应成功后更改需求状态为待评价(100502)
                                    firstmodel.PublishStateId = 100502;
                                    _commonRepository.Modify <T_FARMER_PUBLISHED_DEMAND>(firstmodel, f => f.Id == id);
                                    result.IsSuccess = true;
                                    result.Entity    = model;

                                    //给大农户发送一个通知
                                    _notificationService.Insert(new T_NOTIFICATION
                                    {
                                        MsgContent           = "您的需求有人响应啦,快去看看吧!",
                                        IsPublic             = false,
                                        TargetUserId         = firstmodel.CreateUserId,
                                        NotificationType     = 3,
                                        NotificationSource   = "",
                                        NotificationSourceId = firstmodel.Id
                                    });
                                }
                                else
                                {
                                    result.IsSuccess = false;
                                    result.Message   = ResponeString.NotRepeatApplication;
                                }
                            }
                            else
                            {
                                result.IsSuccess = false;
                                result.Message   = ResponeString.RequirementOver;
                            }
                        }
                        else
                        {
                            result.IsSuccess = false;
                            result.Message   = string.Format("{0} - " + ResponeString.NoJurisdiction, userId.ToString());
                        }
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message   = ResponeString.NotFAccept;
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = ResponeString.NoRequirement;
                }

                return(Json(result));
            }
        }
Example #22
0
 ///<summary>
 ///更改用户
 /// </summary>
 public void ChangeUser(T_USER newuser)
 {
     db.T_USER.Attach(newuser);
     db.Entry(newuser).State = EntityState.Modified;   //直接修改数据库上下文
     db.SaveChanges();
 }
Example #23
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="user">新用户对象</param>
 public void AddUser(T_USER user)
 {
     usersDao.AddUser(user);
 }
Example #24
0
 /// <summary>
 /// 修改用户信息
 /// </summary>
 /// <param name="newuser">新用户对象</param>
 public void ChangeUser(T_USER newuser)
 {
     usersDao.ChangeUser(newuser);
 }
Example #25
0
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="key">被删除用户的主键</param>
 public void DeleUser(T_USER newusser)
 {
     usersDao.DeleUser(newusser);
 }