public static CResult <WebOrderClient> GetCompanyInfo(string orderClientID) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("orderClientID", orderClientID); using (var context = new DeviceMgmtEntities()) { var entity = context.OrderClient.FirstOrDefault(t => t.ID == orderClientID); if (entity == null) { return(new CResult <WebOrderClient>(null, ErrorCode.DataNoExist)); } var webOrderClient = new WebOrderClient() { LogoFile = entity.LogoFile, CompanyContact = entity.CompanyContact, CompanyDescribe = entity.CompanyDescribe, CompanyName = entity.CompanyName, ID = entity.ID, }; LogHelper.Info("result", webOrderClient); return(new CResult <WebOrderClient>(webOrderClient)); } }
public ActionResult UpdateOrderClient(WebOrderClient webOrderClient, string returnUrl) { OrderClientBLL OrderClientBLL = new OrderClientBLL(); CResult <bool> cResult = OrderClientBLL.UpdateOrderClientInfo(webOrderClient); return(JsonContentHelper.GetJsonContent(cResult)); }
public ActionResult AddOrderClient(string returnUrl) { ViewBag.Action = "Add"; ViewBag.ReturnUrl = returnUrl; WebOrderClient webOrderClient = new WebOrderClient(); return(View(webOrderClient)); }
public ActionResult AddOrderClient(WebOrderClient webOrderClient) { OrderClientBLL OrderClientBLL = new OrderClientBLL(); webOrderClient.CreateUserID = this.GetCurrentUserID(); CResult <bool> cResult = OrderClientBLL.InsertOrderClient(webOrderClient); return(JsonContentHelper.GetJsonContent(cResult)); }
public ActionResult UpdateOrderClient(string OrderClientID, string returnUrl) { OrderClientBLL OrderClientBLL = new OrderClientBLL(); var result = OrderClientBLL.GetOrderClientInfoByID(OrderClientID); WebOrderClient webOrderClient = null; if (result.Code == 0) { webOrderClient = result.Data; } ViewBag.ReturnUrl = returnUrl; return(View(webOrderClient)); }
public CResult <bool> InsertOrderClient(WebOrderClient webOrderClient) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("webOrderClient", webOrderClient); using (var context = new DeviceMgmtEntities()) { if (context.OrderClient.Any(t => t.OrderClientName.ToUpper() == webOrderClient.Name.ToUpper() && t.IsValid)) { return(new CResult <bool>(false, ErrorCode.OrderClientNameIsExist)); } var orderClient = new OrderClient(); orderClient.CreateDate = DateTime.Now; orderClient.CreateUserID = webOrderClient.CreateUserID; orderClient.ID = Guid.NewGuid().ToString(); orderClient.OrderClientName = webOrderClient.Name; orderClient.Note = webOrderClient.Note; orderClient.IsValid = true; var webUser = webOrderClient.WebUser; webUser.CreateUserID = webOrderClient.CreateUserID; var userLoginName = webUser.LoginName.ToUpper(); if (context.User.Any(t => t.LoginName.ToUpper() == userLoginName)) { return(new CResult <bool>(false, ErrorCode.LoginNameIsExist)); } var entity = new User() { UserID = Guid.NewGuid().ToString(), LoginName = webUser.LoginName, Password = webUser.Pwd, Name = webUser.UserName, ProjectID = string.Empty, OrderClientID = orderClient.ID, Address = webUser.Address, Telephone = webUser.TelPhone, CreateDate = DateTime.Now, CreateUserID = webUser.CreateUserID, Email = webUser.Email, IsValid = true, Role = (int)RoleType.客户管理员 }; context.OrderClient.Add(orderClient); context.User.Add(entity); return(context.Save()); } }
public ActionResult UpdateAboutUs(WebOrderClient webOrderClient) { webOrderClient.ID = this.GetCurrentOrderClientID(); var cResult = new OrderClientBLL().UpdateCompanyInfo(webOrderClient); if (cResult.Code == 0 && cResult.Data) { var companyInfo = OrderClientBLL.GetCompanyInfo(this.GetCurrentOrderClientID()); if (companyInfo.Code == 0) { Response.Cookies.Add(new HttpCookie("CompanyName", companyInfo.Data.CompanyName)); } } return(JsonContentHelper.GetJsonContent(cResult)); }
public CResult <WebOrderClient> GetOrderClientInfoByID(string orderClientID) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("orderClientID", orderClientID); using (var context = new DeviceMgmtEntities()) { var entity = context.OrderClient.FirstOrDefault(t => t.ID == orderClientID); if (entity == null) { return(new CResult <WebOrderClient>(null, ErrorCode.DataNoExist)); } var webOrderClient = new WebOrderClient() { CreateDate = entity.CreateDate, ID = entity.ID, Note = entity.Note, Name = entity.OrderClientName, }; var user = context.User.FirstOrDefault(t => t.Role == (int)RoleType.客户管理员 && t.OrderClientID == webOrderClient.ID); var webUser = new WebUser { ID = user.UserID, Address = user.Address, Email = user.Email, LoginName = user.LoginName, TelPhone = user.Telephone, Moblie = user.Moblie, UserName = user.Name, }; webOrderClient.WebUser = webUser; LogHelper.Info("result", webOrderClient); return(new CResult <WebOrderClient>(webOrderClient)); } }
public CResult <bool> UpdateCompanyInfo(WebOrderClient companyInfo) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("companyInfo", companyInfo); using (var context = new DeviceMgmtEntities()) { var entity = context.OrderClient.FirstOrDefault(t => t.ID == companyInfo.ID); if (entity == null) { return(new CResult <bool>(false, ErrorCode.DataNoExist)); } entity.CompanyContact = companyInfo.CompanyContact; entity.CompanyDescribe = companyInfo.CompanyDescribe; entity.CompanyName = companyInfo.CompanyName; context.Entry(entity).State = EntityState.Modified; return(context.Save()); } }
public CResult <bool> UpdateOrderClientInfo(WebOrderClient webOrderClient) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("webOrderClient", webOrderClient); using (var context = new DeviceMgmtEntities()) { var entity = context.OrderClient.FirstOrDefault(t => t.ID == webOrderClient.ID); if (entity == null) { return(new CResult <bool>(false, ErrorCode.DataNoExist)); } var name = webOrderClient.Name.ToUpper(); if (context.OrderClient.Any(t => t.OrderClientName.ToUpper() == name && t.IsValid && t.ID != webOrderClient.ID)) { return(new CResult <bool>(false, ErrorCode.OrderClientNameIsExist)); } entity.OrderClientName = webOrderClient.Name; entity.Note = webOrderClient.Note; var user = context.User.FirstOrDefault(t => t.Role == (int)RoleType.客户管理员 && t.OrderClientID == webOrderClient.ID); if (user == null) { return(new CResult <bool>(false, ErrorCode.DataNoExist)); } var webUser = webOrderClient.WebUser; user.Address = webUser.Address; user.Email = webUser.Email; user.Name = webUser.UserName; user.Telephone = webUser.TelPhone; user.Moblie = webUser.Moblie; context.Entry(entity).State = EntityState.Modified; return(context.Save()); } }