示例#1
0
        public IHttpActionResult GetRelatedRequisitions([FromBody] EmailViewModel model)
        {
            var requisitions = requisitionService.FindRequisitionsByDepartment(new UserService(context).FindUserByEmail(model.Email).Department).OrderByDescending(r => r.CreatedDateTime);

            if (requisitions.Count() == 0)
            {
                return(NotFound());
            }

            return(Ok(requisitions.Select(requisition => new RequisitionMobileViewModel()
            {
                RequisitionId = requisition.RequisitionId,
                RequestorName = $"{requisition.CreatedBy.FirstName} {requisition.CreatedBy.LastName}",
                RequestedDate = requisition.CreatedDateTime.ToShortDateString(),
                Remarks = requisition.EmployeeRemarks == null ? "" : requisition.EmployeeRemarks,
                HeadRemarks = requisition.HeadRemarks == null ? "" : requisition.HeadRemarks,
                Status = requisition.Status != null ? requisition.Status.Name : "",
                RequisitionDetails = requisition.RequisitionDetails.Select(d => new RequisitionDetailMobileViewModel()
                {
                    ItemCode = d.ItemCode,
                    Description = d.Item.Description,
                    Qty = d.Quantity,
                    Uom = d.Item.Uom,
                }).ToList()
            })));
        }
示例#2
0
        public void FindByDepartmentTest()
        {
            // Arrange
            requisitionService.Save(new Requisition()
            {
                RequisitionId   = "RQSERVTEST",
                Department      = new DepartmentRepository(context).FindById("ENGL"),
                CreatedDateTime = DateTime.Now,
            });

            // Act
            var result = requisitionService.FindRequisitionsByDepartment(new DepartmentRepository(context).FindById("ENGL"));

            // Assert
            result.ToList().ForEach(r => Assert.AreEqual("ENGL", r.Department.DepartmentCode));
        }