public IActionResult SaveSystemWorkPlace([Bind("ID,Name,URL,Description,SortCode")] SystemWorkPlaceVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _BoRepository.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo = new SystemWorkPlace();
                }
                boVM.MapToBo(bo);
                _BoRepository.AddOrEditAndSave(bo);

                MenuItemCollection.UpdateMainTopMenuItem(bo);

                var saveStatus = new EditAndSaveStatus()
                {
                    SaveOk = true, StatusMessage = "../../SystemConfig/Index"
                };
                return(Json(saveStatus));
            }
            else
            {
                return(PartialView("../../Views/ApplicationManagement/SystemConfig/_CreateOrEditForSystemWorkPlace", boVM));
            }
        }
Exemple #2
0
        public ActionResult Save(SystemWorkPlaceVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new SystemWorkPlace();
                    bo.ID = boVM.ID;
                }

                var appID = Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId;

                var appInfo = _Service.GetSingleRelevance <ApplicationInformation>(appID);
                if (appInfo == null)
                {
                    appInfo             = new ApplicationInformation();
                    appInfo.ID          = appID;
                    appInfo.AppID       = appID;
                    appInfo.Name        = "";
                    appInfo.Description = "";
                    appInfo.SortCode    = "001";
                    _Service.AddRelevance <ApplicationInformation>(appInfo);
                    _Service.Save();
                }
                boVM.MapToBo(bo, appInfo);
                _Service.AddOrEditAndSave(bo);

                return(Json(PageComponentRepository <SystemWorkPlaceVM> .SaveOK(true, "1", "")));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                var editor = PageComponentRepository <SystemWorkPlaceVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Exemple #3
0
        public ActionResult Save(DepartmentVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new Department();
                    bo.ID = boVM.ID;
                }
                var parentBo = bo; // 对于具有层次结构关系的实体类,如果没有选择上级层次对象,缺省处理为自身,即为根节点对象。
                if (!String.IsNullOrEmpty(boVM.ParentItemID))
                {
                    parentBo = _Service.GetSingle(Guid.Parse(boVM.ParentItemID));
                }

                boVM.MapToBo(bo, parentBo);

                _Service.AddOrEditAndSave(bo);

                var typeID            = bo.ParentDapartment.ID.ToString();
                var extessionFunction = "RefreshTreeView"; // 约定数据持久化之后,除了执行返回列表的方法外,还需要执行的刷新导航树的另外的方法

                return(Json(PageComponentRepository <DepartmentVM> .SaveOK(true, "1", typeID, extessionFunction)));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

                var editor = PageComponentRepository <DepartmentVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Exemple #4
0
        public ActionResult Save(DepartmentTypeVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new DepartmentType();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);
                _Service.AddOrEditAndSave(bo);

                // 这里采用直接跳转的方式,避开 AjaxForm 回转处理,跳转的时候,在本框架中,一般跳回Index,
                // 如果需要定位页码,类型等,请考虑 Index 中配置好参数,在下面的跳转调用中对应配置好参数即可。
                return(JavaScript("window.location.href ='../DepartmentType/Index';"));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                //var editor = PageComponentRepository<DepartmentTypeVM>.UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;
                var editor = PageComponentRepository <DepartmentTypeVM> .UpdateCreateOrEditPage(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Exemple #5
0
        /// <summary>
        ///  处理广告的图片上传
        /// </summary>
        /// <param name="entity"></param>
        private void UploadAdvertisementIMG(IEntity entity)
        {
            try
            {
                var image = Request.Form.Files.First();
                if (image != null)
                {
                    var    objectImg     = _businessImage.FindBy(x => x.RelevanceObjectId == entity.Id).FirstOrDefault();
                    var    currImageName = image.FileName;
                    var    timeForFile   = (DateTime.Now.ToString("yyyyMMddHHmmss") + "-").Trim();
                    string extensionName = currImageName.Substring(currImageName.LastIndexOf("."));
                    var    imageName     = ContentDispositionHeaderValue
                                           .Parse(image.ContentDisposition)
                                           .FileName
                                           .Trim('"')
                                           .Substring(image.FileName.LastIndexOf("\\") + 1);
                    var newImageName = timeForFile + Guid.NewGuid() + extensionName;
                    var boPath       = "../../images/UploadImages/" + objectImg.Type.ToString() + "/" + newImageName;
                    var imagePath    = _hostingEnv.WebRootPath + $@"\images\UploadImages\{objectImg.Type.ToString()}";
                    imageName = _hostingEnv.WebRootPath + $@"\images\UploadImages\{objectImg.Type.ToString()}\{newImageName}";

                    Directory.CreateDirectory(imagePath); //创建目录
                    using (FileStream fs = System.IO.File.Create(imageName))
                    {
                        image.CopyTo(fs);
                        fs.Flush();
                    }
                    if (objectImg.PhysicalPath != null)
                    {
                        System.IO.File.Delete(Path.Combine(objectImg.PhysicalPath, "\\" + objectImg.Name));
                    }
                    objectImg.Name         = newImageName;
                    objectImg.PhysicalPath = imagePath;
                    objectImg.UploadPath   = boPath;
                    _businessImage.AddOrEditAndSave(objectImg);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #6
0
        public async Task <IActionResult> Payment(string info)
        {
            var pay      = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Payment> >(info);
            var payVM    = pay.FirstOrDefault();
            var userName = User.Identity.Name;

            if (userName == null)
            {
                return(View("../../Views/Home/Logon"));
            }
            var user = await _UserManager.FindByNameAsync(userName);

            var result = await _SignInManager.PasswordSignInAsync(user.UserName, payVM.Password, false, lockoutOnFailure : false);

            if (result.Succeeded)
            {
                var allOrderItem = await _OrderItemRepository.GetAllIncludingAsyn(x => x.ItemForOrder);

                var orderItem = allOrderItem.Where(x => x.ItemForOrder.ID.ToString() == payVM.OrderID);
                var orders    = await _OrderRepository.FindByAsyn(x => x.ID.ToString() == payVM.OrderID);

                foreach (var item in orderItem)
                {
                    item.State = (SK_WM_OrderState.Orderstate.待发货).ToString();
                    _OrderItemRepository.AddOrEditAndSave(item);
                }
                if (orders.FirstOrDefault() != null)
                {
                    var order = orders.FirstOrDefault();
                    order.State = (SK_WM_OrderState.Orderstate.待发货).ToString();
                    _OrderRepository.AddOrEditAndSave(order);
                }

                return(Json(new { result = true, messsage = "支付成功" }));
            }
            else
            {
                return(Json(new { result = false, message = "支付密码错误,请检查后重新处理。" }));
            }
        }
Exemple #7
0
        public ActionResult Save(JobLevelVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new JobLevel();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);
                _Service.AddOrEditAndSave(bo);

                return(Json(PageComponentRepository <JobLevelVM> .SaveOK(true, "1", "")));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                var editor = PageComponentRepository <JobLevelVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Exemple #8
0
        public ActionResult Save(PersonVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo    = new Person();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);

                var creID          = Guid.Parse(boVM.CredentialsTypeID);
                var credentialType = _Service.GetSingleRelevance <CredentialsType>(creID);

                var jlID     = Guid.Parse(boVM.JobLevelID);
                var jobLevel = _Service.GetSingleRelevance <JobLevel>(jlID);

                var jtID     = Guid.Parse(boVM.JobTitleID);
                var jobTitle = _Service.GetSingleRelevance <JobTitle>(jtID);

                var dID  = Guid.Parse(boVM.ParentItemID);
                var dept = _Service.GetSingleRelevance <Department>(dID);

                bo.Name = bo.FirstName + bo.LastName;
                if (String.IsNullOrEmpty(bo.SortCode))
                {
                    bo.SortCode = BusinessEntityComponentsFactory.SortCodeByDefaultDateTime <Person>();
                }

                bo.CredentialsType = credentialType;
                bo.JobLevel        = jobLevel;
                bo.JobTitle        = jobTitle;
                bo.Department      = dept;
                bo.UpdateTime      = DateTime.Now;
                bo.IsActivePerson  = true;

                _Service.AddOrEditAndSave(bo);

                //var personInDepartment = _Service.GetSingleRelevanceBy<PersonsInDepartment>(p => p.Person.ID == bo.ID && p.Department.ID == dID);
                //if (personInDepartment == null)
                //{
                //    personInDepartment = new PersonsInDepartment() { Department = dept, Person = bo };
                //    _Service.AddAndSaveRelevance<PersonsInDepartment>(personInDepartment);
                //}

                var typeID = boVM.ParentItemID;
                return(Json(PageComponentRepository <PersonVM> .SaveOK(true, "1", typeID)));
            }
            else
            {
                var vItems = new List <ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name         = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true);

                boVM.CredentialsTypeCollection = BusinessCollectionFactory <CredentialsType> .GetPlainFacadeItemCollection();

                boVM.JobLevelCollection = BusinessCollectionFactory <JobLevel> .GetPlainFacadeItemCollection();

                boVM.JobTitleCollection = BusinessCollectionFactory <JobTitle> .GetPlainFacadeItemCollection();

                var editor = PageComponentRepository <PersonVM> .UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return(Json(editor));
            }
        }
Exemple #9
0
        public async Task <IActionResult> AddToShoppingCar(SK_WM_ShopCarGoodsItem scItem)
        {
            try
            {
                //var status = false;
                var username = User.Identity.Name;
                if (username == null)
                {
                    //return View("../../Views/Home/Logon");
                    Json(new { isOK = false, message = "请登录后再执行操作" });
                }
                var user = await _UserManager.FindByNameAsync(username);

                if (user == null)
                {
                    //return View("../../Views/Home/Logon");
                    Json(new { isOK = false, message = "请登录后再执行操作" });
                }

                var shopcar = await _ShopCarRepository.FindByAsyn(x => x.BelongToUserID == user.Id);

                if (shopcar.Count() == 0)
                {
                    var shopCar = new SK_WM_ShopCar()
                    {
                        BelongToUserID = user.Id,
                        ShopCarForUser = user
                    };
                    await _ShopCarRepository.AddOrEditAndSaveAsyn(shopCar);

                    shopcar = await _ShopCarRepository.FindByAsyn(x => x.BelongToUserID == user.Id);
                }

                var goods = _GoodsRepository.GetSingleBy(x => x.ID == Guid.Parse(scItem.GoodsID));

                var imgs = await _ImageRepository.FindByAsyn(x => x.RelevanceObjectID == goods.ID);

                var img = imgs.Where(x => x.IsForTitle == true).FirstOrDefault();

                var shop = _ShopRepository.GetSingleBy(x => x.ID == Guid.Parse(goods.BelongToShopID));

                //查询该用户的购物车下的所有商品
                var goodsItem = await _ShopCarGoodsItemRepository.FindByAsyn(x => x.BelongToShopCarID == shopcar.FirstOrDefault().ID.ToString());

                //查询该用户购物车内的商品内是否有正要添加的商品
                var hasGoods = goodsItem.Where(x => x.GoodsName == scItem.GoodsName);

                var sItem = new SK_WM_ShopCarGoodsItem();
                if (hasGoods.Count() == 0)//判断原购物车是否有要添加的商品、如果有就在原来的基础上修改数量及总价、否则直接添加新的
                {
                    sItem = new SK_WM_ShopCarGoodsItem()
                    {
                        BelongToShopCarID = shopcar.FirstOrDefault().ID.ToString(),
                        shopCar           = shopcar.FirstOrDefault(),
                        GoodsID           = scItem.GoodsID,
                        Count             = scItem.Count,
                        Price             = scItem.Price,
                        TotalPrice        = (scItem.Count * decimal.Parse(scItem.Price)).ToString(),
                        ShopName          = shop.Name,
                        GoodsName         = goods.Name,
                        ImgPath           = img.UploadPath,
                        CreateOrderTime   = DateTime.Now,
                    };
                    _ShopCarGoodsItemRepository.AddOrEditAndSave(sItem);
                }
                else
                {
                    var hItem = hasGoods.FirstOrDefault();
                    hItem.Count      = scItem.Count + hItem.Count;
                    hItem.TotalPrice = (hItem.Count * decimal.Parse(scItem.Price)).ToString();
                    _ShopCarGoodsItemRepository.AddOrEditAndSave(hItem);
                }


                return(Json(new { isOK = true, message = "添加购物车成功" }));
            }
            catch (Exception)
            {
                return(Json(new { isOK = false, message = "添加失败,请检查登录状态后再执行操作" }));
            }
        }