public int LoginOn(string userAccount, string userPassword) { string password = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassword, "md5"); bool exist = webUserservice.ExistUser(userAccount, password); if (exist) { WebUser User = webUserservice.GetWebUserByAccount(userAccount, password); WebUserService webuserservice = new WebUserService(); WebPeopleService webpeopleservice = new WebPeopleService(); //userAccount=UserName if (User.IsLock) { //被锁定 return(100); } else { SessionHelper.SetSession("UserName", userAccount); WebUser webuser = webuserservice.GetWebUserByAccount(userAccount); SessionHelper.SetSession("UserID", webuser.UserID); SessionHelper.SetSession("PositionCode", webuser.PositionCode); WebPeople webpeople = new WebPeople(); WebWorker webWorker = new WebWorker(); if (webpeopleservice.IsHaveuser(webuser.UserID) && webuser.PositionCode == "WebPeople") { webpeople = webpeopleservice.GetWebPeopleByUserID(webuser.UserID); SessionHelper.SetSession("PositionID", webpeople.PeopleID); } else if (webWorkerService.IsHaveWorker(webuser.UserID) && (webuser.PositionCode == "WebWorkerLeader" || webuser.PositionCode == "WebWorker")) { webWorker = webWorkerService.GetWebWorkerByUserID(webuser.UserID); SessionHelper.SetSession("PositionID", webWorker.WorkerID); } SessionHelper.SetSession("NickName", webuser.NickName); return(200); } } else { return(500); } }
public ActionResult AddAndUpdateUserAndWorkerModel(UserAndWorkerModel model) { string workercategory = ""; if(model.PositionCode== "WebWorkerLeader") { workercategory = "装修工长"; } else if (model.PositionCode == "WebWorker") { workercategory = "装修工人"; } int result = 0; string Password = ""; if (model.Password != null) { Password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "md5"); } WebUser user = new WebUser() { UserID = model.UserID, UserName = model.UserName, Password = Password, NickName = model.NickName, TrueName = model.TrueName, Email = model.Email, Sex = model.Sex, PositionCode = model.PositionCode, Telephone = model.Telephone, ProvinceID = model.ProvinceID, ProvinceName = model.ProvinceName, CityID = model.CityID, CityName = model.CityName, AreasID = model.AreasID, AreasName = model.AreasName, IsLock = model.IsLock, InUser = model.InUser }; WebWorker worker = new WebWorker() { WorkerName=model.TrueName, WorkerCategory= workercategory, WorkerPhone=model.Telephone, WorkerMail=model.Email, WorkerInfo=model.WorkerInfo, WorkerMotto=model.WorkerMotto, ProvinceID=model.ProvinceID, ProvinceName=model.ProvinceName, CityID=model.CityID, CityName=model.CityName, AreasID=model.AreasID, AreasName=model.AreasName, WorkYearsID=model.WorkYearsID, WorkYears=model.WorkYears, PriceName=model.PriceName, GoodAtStyle=model.GoodAtStyle, WorkerPositionID=model.WorkerPositionID, WorkerPosition=model.WorkerPosition, IsApproved=model.InUser, Address= model.Address }; if (model != null && model.UserID > 0) { result = webuserservice.UpdateWebUser(user); WebUser webu = webuserservice.GetWebUserByAccount(model.UserName); worker.UserID = webu.UserID; result = workSer.UpdateWebWorkerFromCenter(worker); } else { result = webuserservice.AddWebUser(user); WebUser webu= webuserservice.GetWebUserByAccount(model.UserName); worker.UserID = webu.UserID; result = workSer.AddWebWorker(worker); } return Json(new { retCode = result }, JsonRequestBehavior.AllowGet); }