예제 #1
0
        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));
            }
        }
예제 #2
0
        public ActionResult UpdateOrderClient(WebOrderClient webOrderClient, string returnUrl)
        {
            OrderClientBLL OrderClientBLL = new OrderClientBLL();

            CResult <bool> cResult = OrderClientBLL.UpdateOrderClientInfo(webOrderClient);

            return(JsonContentHelper.GetJsonContent(cResult));
        }
예제 #3
0
        public ActionResult AddOrderClient(string returnUrl)
        {
            ViewBag.Action    = "Add";
            ViewBag.ReturnUrl = returnUrl;
            WebOrderClient webOrderClient = new WebOrderClient();

            return(View(webOrderClient));
        }
예제 #4
0
        public ActionResult AddOrderClient(WebOrderClient webOrderClient)
        {
            OrderClientBLL OrderClientBLL = new OrderClientBLL();

            webOrderClient.CreateUserID = this.GetCurrentUserID();
            CResult <bool> cResult = OrderClientBLL.InsertOrderClient(webOrderClient);

            return(JsonContentHelper.GetJsonContent(cResult));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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());
            }
        }
예제 #7
0
        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));
        }
예제 #8
0
        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));
            }
        }
예제 #9
0
        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());
            }
        }
예제 #10
0
        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());
            }
        }