public int Register(string userAccount, string userPassword, string PositionCode, int PositionType) { bool bit = webUserservice.IsHaveuserAccount(userAccount); if (bit) { //存在 return(0); } else { WebUser webuser = new WebUser { UserName = userAccount, Password = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassword, "md5"), Telephone = userAccount, PositionCode = PositionCode, PositionType = PositionType }; int result = webUserservice.AddWebUser(webuser); int userid = webUserservice.GetWebUserByAccount(userAccount).UserID; if (PositionCode == "WebWorkerLeader" || PositionCode == "WebWorker") { WebWorker worker = new WebWorker { WorkerPhone = userAccount, UserID = userid }; if (PositionCode == "WebWorkerLeader") { worker.WorkerCategory = "装修工长"; } else { worker.WorkerCategory = "装修工人"; } webWorkerService.AddWebWorker(worker); } return(result); } }
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); }
public int UpdatePeople() { WebUser webuser = new WebUser { UserID = Convert.ToInt32(Request["UserID"]), NickName = Request["NickName"], TrueName = Request["TrueName"], Email = Request["Email"], //Address = Request["Address"], Sex = Request["Sex"], ProvinceID = Request["ProvinceID"], ProvinceName = Request["ProvinceName"], CityID = Request["CityID"], CityName = Request["CityName"], AreasID = Request["AreasID"], AreasName = Request["AreasName"], Img = Request["PeopleImage"], thumbnailImage = Request["thumbnailImage"], }; webUserservice.UpdateWebUserFromCenter(webuser); //设计师 if (Request["PositionCode"] == "WebPeople") { WebPeople webpeo = new WebPeople { //Address = Request["Address"], //PeopleCategory = Request["UserType"], PeopleImage = Request["PeopleImage"], thumbnailImage = Request["thumbnailImage"], PeoplePhone = Request["PeoplePhone"], PeopleName = Request["TrueName"], PeopleMail = Request["Email"], ProvinceID = Request["ProvinceID"], ProvinceName = Request["ProvinceName"], CityID = Request["CityID"], CityName = Request["CityName"], AreasID = Request["AreasID"], AreasName = Request["AreasName"], }; if (webpeopleservice.IsHaveuser(Convert.ToInt32(Request["UserID"]))) { WebPeople webpeople = webpeopleservice.GetWebPeopleByUserID(Convert.ToInt32(Request["UserID"])); webpeo.PeopleID = webpeople.PeopleID; webpeopleservice.UpdateWebPeopleFromCenter(webpeo); } else { webpeo.UserID = Convert.ToInt32(Request["UserID"]); webpeopleservice.AddWebPeople(webpeo); } } else if (Request["PositionCode"] == "WebWorkerLeader" || Request["PositionCode"] == "WebWorker") { WebWorker worker = new WebWorker { WorkerName = Request["TrueName"], WorkerPhone = Request["PeoplePhone"], WorkerMail = Request["Email"], WorkerImage = Request["PeopleImage"], thumbnailImage = Request["thumbnailImage"], ProvinceID = Request["ProvinceID"], ProvinceName = Request["ProvinceName"], CityID = Request["CityID"], CityName = Request["CityName"], AreasID = Request["AreasID"], AreasName = Request["AreasName"], }; if (Request["PositionCode"] == "WebWorkerLeader") { worker.WorkerCategory = "装修工长"; } else { worker.WorkerCategory = "装修工人"; } if (webWorkerService.IsHaveWorker(Convert.ToInt32(Request["UserID"]))) { WebWorker WebWorker = webWorkerService.GetWebWorkerByUserID(Convert.ToInt32(Request["UserID"])); worker.WorkerID = WebWorker.WorkerID; webWorkerService.UpdateWebWorkerFromCenter(worker); } else { worker.UserID = Convert.ToInt32(Request["UserID"]); webWorkerService.AddWebWorker(worker); } } return(1); }