public ActionResult InspectionConfirm()
        {
            var list = new InspectionFormService().QueryConfirm(this.UserContext.RootUnitId);

            var unitService    = new UnitService();
            var productService = new ProductService();

            ViewBag.Context = new
            {
                List = list.Select(item =>
                {
                    var unit    = unitService.Get(item.ApplyUnitId).Name;
                    var product = productService.Get(item.ProductId).Name;

                    return(new
                    {
                        Id = item.Id,
                        orderDetailId = item.OrderDetailId,
                        FormNo = item.OrderFormNo,
                        Unit = unit,
                        Product = product,
                        InspectionCount = item.InspectionCount,
                        ScanCount = new GoodsStateService().CountValid(item.Id, FormType.Inspection)
                    });
                })
            };

            return(View());
        }
Example #2
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IUnitService, IUnitRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Unit>(null));
            var service = new UnitService(mock.LoggerMock.Object,
                                          mock.MediatorMock.Object,
                                          mock.RepositoryMock.Object,
                                          mock.ModelValidatorMockFactory.UnitModelValidatorMock.Object,
                                          mock.DALMapperMockFactory.DALUnitMapperMock,
                                          mock.DALMapperMockFactory.DALCallAssignmentMapperMock,
                                          mock.DALMapperMockFactory.DALUnitOfficerMapperMock);

            ApiUnitServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
        public JsonNetResult QueryUnits(string parentId, string condition, PagerInfo pager)
        {
            try
            {
                var service = new UnitService();
                if (!this.IsAdmin)
                {
                    parentId = UserContext.RootUnitId;
                }
                var list = service.QueryUnits(condition, parentId, pager);

                var result = new List <dynamic>();
                var dic    = GetHospitalReceipts(parentId);
                foreach (var item in list)
                {
                    ReceiptInfoModel receipt;
                    if (string.IsNullOrEmpty(item.DefaultReceiptId) || !dic.TryGetValue(item.DefaultReceiptId, out receipt))
                    {
                        receipt = null;
                    }

                    result.Add(new
                    {
                        Id               = item.Id,
                        Name             = item.Name,
                        Description      = item.Description,
                        ShortCode        = item.ShortCode,
                        ContactId        = item.ContactId,
                        ReceiptTitle     = receipt == null ? "" : receipt.Title,
                        Tax              = receipt == null ? 0 : receipt.Tax,
                        VendorName       = service.Get(item.RootId).Name,
                        ParentId         = item.ParentId,
                        BusinessTypeName = UnitBusinessTypeName.GetName(item.BusinessType)
                    });
                }

                return(JsonNet(new ResponseResult(true, result, pager)));
            }
            catch (Exception e)
            {
                return(JsonNet(new ResponseResult(e)));
            }
        }
        private IDictionary <UnitType, List <object> > GetRoots(string userId)
        {
            var user        = new UserService().Get(userId);
            var unitService = new UnitService();

            var unit = unitService.Get(user.UnitId);

            if (unit.Type == UnitType.None)
            {
                return(null);
            }

            var dic = new Dictionary <UnitType, List <object> >();

            if (unit.Type == UnitType.Hospital || unit.Type == UnitType.HospitalUnit)
            {
                var roots = unitService.GetByRootId(Constant.DEFAULT_UNIT_ROOT_ID);

                dic[UnitType.Hospital] = roots.Where(item => item.Type == UnitType.Hospital).Select(item =>
                                                                                                    new
                {
                    Id   = item.Id,
                    Name = item.Name
                }).ToList <object>();
            }
            else
            {
                var vendor = new UnitService().Get(unit.RootId == Constant.DEFAULT_UNIT_ROOT_ID ? unit.Id : unit.RootId);
                dic[UnitType.Vendor] = new List <object>()
                {
                    new
                    {
                        Id   = vendor.Id,
                        Name = vendor.Name
                    }
                };
            }

            return(dic);
        }
Example #5
0
        public JsonNetResult GetUserRoot(string account)
        {
            UserEntity user = null;
            UnitModel  unit = null;
            IList <SystemPrivilegeEntity> privilege = null;

            if (UserService.TryGetUserByAccount(account, out user))
            {
                unit = _unitService.Get(user.UnitId);
            }
            if (unit != null)
            {
                privilege = _systemPrivilegeService.GetByObjectId(unit.Id, 0);
            }
            return(JsonNet(new ResponseResult(true, new
            {
                user_id = user == null?"": user.Id,
                unit_id = unit == null ? "" : unit.Id,
                unit_Type = unit?.Type.GetHashCode() ?? 0,
                unit_ParentId = unit == null ? "" : unit.ParentId,
                SystemPrivilege = privilege?.Select(m => new { m.Id, m.FunKey })
            })));
        }
        public JsonNetResult GetFormApproveList(FormType formType)
        {
            try
            {
                if (formType == FormType.None)
                {
                    throw new Exception("The audit form is not being chosen.");
                }

                var list = new FormApproveListService().Get(formType);

                var unitService = new UnitService();
                var userService = new UserService();

                var result = new List <dynamic>();
                var index  = 1;
                foreach (var item in list)
                {
                    if (item.ApproverType == ApproverType.ChoosePerson)
                    {
                        var person = userService.Get(item.ApproverId);
                        result.Add(new
                        {
                            Id       = item.Id,
                            FormType = item.FormType,
                            Type     = new
                            {
                                Value = item.ApproverType,
                                Name  = "指定人员"
                            },
                            Approver = new
                            {
                                Id   = item.ApproverId,
                                Name = person == null ? string.Empty : person.Name
                            },
                            Sequence = index
                        });
                    }
                    else if (item.ApproverType == ApproverType.ChooseUnitManager)
                    {
                        var unit = unitService.Get(item.ApproverId);
                        result.Add(new
                        {
                            Id       = item.Id,
                            FormType = item.FormType,
                            Type     = new
                            {
                                Value = item.ApproverType,
                                Name  = "部门主管"
                            },
                            Approver = new
                            {
                                Id   = item.ApproverId,
                                Name = unit == null ? string.Empty : unit.Name
                            },
                            Sequence = index
                        });
                    }
                    else
                    {
                        result.Add(new
                        {
                            Id       = item.Id,
                            FormType = item.FormType,
                            Type     = new
                            {
                                Value = item.ApproverType,
                                Name  = item.ApproverType == ApproverType.Applyer ? "申请人" : "申请部门主管"
                            },
                            Sequence = index
                        });
                    }

                    index++;
                }

                return(JsonNet(new ResponseResult(true, result)));
            }
            catch (Exception e)
            {
                return(JsonNet(new ResponseResult(false, e)));
            }
        }
Example #7
0
 public JsonResult GetbyID(int ID)
 {
     return(Json(service.Get(ID), JsonRequestBehavior.AllowGet));
 }
Example #8
0
 public IActionResult Get(int pageNo, int pageSize, string textSearch)
 {
     return(Ok(_unitService.Get(pageNo, pageSize, textSearch)));
 }