public void Should_map_properties_for_update_hearing_request()
        {
            var username          = "******";
            var scheduledDateTime = new DateTime(2020, 12, 12);
            var caseRequest       = new CaseRequest {
                Name = "casename", Number = "casenumber"
            };

            var source = new EditHearingRequest
            {
                HearingRoomName   = "roomname",
                HearingVenueName  = "venuename",
                OtherInformation  = "other information",
                ScheduledDateTime = scheduledDateTime,
                ScheduledDuration = 45,
                Case = new EditCaseRequest {
                    Name = caseRequest.Name, Number = caseRequest.Number
                },
                QuestionnaireNotRequired = false,
                AudioRecordingRequired   = false
            };

            var result = HearingUpdateRequestMapper.MapTo(source, username);

            result.HearingRoomName.Should().Be(source.HearingRoomName);
            result.HearingVenueName.Should().Be(source.HearingVenueName);
            result.ScheduledDateTime.Should().Be(scheduledDateTime);
            result.ScheduledDuration.Should().Be(source.ScheduledDuration);
            result.OtherInformation.Should().Be(source.OtherInformation);
            result.Cases.Should().BeEquivalentTo(caseRequest);
            result.QuestionnaireNotRequired.Should().BeFalse();
            result.AudioRecordingRequired.Should().BeFalse();
        }
Ejemplo n.º 2
0
 public MaternityBenefitsCase(CaseRequest request)
 {
     Id              = Guid.NewGuid();
     NumWeeks        = request.NumWeeks;
     MaxWeeklyAmount = request.MaxWeeklyAmount;
     Percentage      = request.Percentage;
 }
 public void Should_validate_CaseNumber_and_name_with_length_zero_as_error()
 {
     var shortString = "";
     var testRequest = new CaseRequest { Number = shortString, Name = shortString };
     var result = _validator.Validate(testRequest);
     Assert.That(result.Errors.All(o => o.ErrorMessage.Contains("must not be empty.")));
     Assert.That(result.Errors.Count == 2);
 }
Ejemplo n.º 4
0
        public JsonResult SelectCases(CaseRequest request)
        {
            //EF Core 多对多关系查询
            var datas = _db.Cases
                        /*筛选条件*/
                        .WhereIf(request.IndustryID != null, x => x.IndustryCases.Any(b => b.IndustryID == request.IndustryID))
                        .WhereIf(request.ColorID != null, x => x.ColorCases.Any(b => b.ColorID == request.ColorID))
                        .WhereIf(request.ProductID != null, x => x.ProductCases.Any(b => b.ProductID == request.ProductID))
                        .WhereIf(request.ClientID != null, x => x.ClientCases.Any(b => b.ClientID == request.ClientID))
                        /*包含关系*/
                        .Include(x => x.IndustryCases)
                        .Include(x => x.ColorCases)
                        .Include(x => x.ProductCases)
                        .Include(x => x.ClientCases)
                        /*选择属性*/
                        .Select(x => new
            {
                x.ID,
                x.Name,
                x.Cover,
                Industries = x.IndustryCases.Select(i => new
                {
                    i.Industry.ID,
                    i.Industry.Name
                }),
                Colors = x.ColorCases.Select(c => new
                {
                    c.Color.ID,
                    c.Color.Name,
                    c.Color.Value
                }),
                Products = x.ProductCases.Select(p => new
                {
                    p.Product.ID,
                    p.Product.Name
                }),
                Clients = x.ClientCases.Select(c => new
                {
                    c.Client.ID,
                    c.Client.Name
                })
            });

            CaseResponse response = new CaseResponse();

            response.IndustryID = request.IndustryID;
            response.ColorID    = request.ColorID;
            response.ProductID  = request.ProductID;
            response.ClientID   = request.ClientID;
            response.Page       = request.Page;
            response.Limit      = request.Limit;
            response.Total      = datas.Count();

            response.Data = datas.OrderBy(x => x.ID).Skip((request.Page - 1) * request.Limit).Take(request.Limit).ToList();

            return(Json(response));
        }
Ejemplo n.º 5
0
 public static MaternityBenefitsCase Convert(CaseRequest caseModel)
 {
     return(new MaternityBenefitsCase()
     {
         Id = Guid.NewGuid(),
         NumWeeks = caseModel.NumWeeks,
         MaxWeeklyAmount = caseModel.MaxWeeklyAmount,
         Percentage = caseModel.Percentage
     });
 }
Ejemplo n.º 6
0
        private void AddCases()
        {
            var caseRequest = new CaseRequest
            {
                Name       = GenerateRandomCaseName(),
                Number     = GenerateRandom.CaseNumber(_randomNumber),
                IsLeadCase = HearingData.IS_LEAD_CASE
            };

            _request.Cases.Add(caseRequest);
        }
        public void Should_validate_case_request()
        {
            var testRequest = new CaseRequest
            {
                Name = "case name",
                Number = "case number 1"
            };

            var result = _validator.Validate(testRequest);
            Assert.That(result.Errors.Count == 0);
        }
        public void Should_validate_CaseNumber_and_name_with_length_greater_then_255_as_error()
        {
        const string CaseNumber_MESSAGE = "Case number is required between 1 - 255 characters";
         const string CaseName_MESSAGE = "Case name is required between 1 - 255 characters";

        var longString = new String('a', 257);
            var testRequest = new CaseRequest { Number = longString, Name=longString };
            var result = _validator.Validate(testRequest);
            Assert.That(result.Errors.Any(o => o.PropertyName == "Number" && o.ErrorMessage == CaseNumber_MESSAGE));
            Assert.That(result.Errors.Any(o => o.PropertyName == "Name" && o.ErrorMessage == CaseName_MESSAGE));
        }
Ejemplo n.º 9
0
        public ActionResult AddEdit(CaseViewModel caseViewModel)
        {
            CaseRequest caseToSave = new CaseRequest
            {
                Case    = caseViewModel.Case.CreateFromClientToServer(),
                OrderId = caseViewModel.OrderId,
                Charges = caseViewModel.Charges.Select(x => x.CreateFromClientToServer()).ToList()
            };

            caseToSave.Case.OrderId = caseViewModel.OrderId;
            caseService.SaveCase(caseToSave);
            {
                TempData["message"] = new MessageViewModel {
                    Message = "Case Detail Saved", IsSaved = true
                };
                return(RedirectToAction("Index", "Order"));
            }
        }
Ejemplo n.º 10
0
        public async Task Save([FromForm] CaseRequest input)
        {
            string fileLocation = UploadFile.CreateFolderIfNotExists(RootFolder, $@"{UploadFolder}\{CaseFolder}");

            if (input.Id.HasValue)
            {
                var data = await WorkScope.GetAll <Case>().FirstOrDefaultAsync(x => x.Id == input.Id);

                if (data == null)
                {
                    throw new UserFriendlyException("Không tồn tại case");
                }

                if (input.Images?.Count > 0)
                {
                    var images = input.ImagePaths ?? new List <string>();
                    foreach (var item in input.Images)
                    {
                        string fileName = await UploadFile.UploadAsync(fileLocation, item);

                        images.Add($@"{UploadFolder}\{CaseFolder}\{fileName}");
                    }
                    data.ImageString = string.Join("-", images);
                }
                ObjectMapper.Map(input, data);
            }
            else
            {
                var data = ObjectMapper.Map <Case>(input);
                if (input.Images?.Count > 0)
                {
                    var images = new List <string>();
                    foreach (var item in input.Images)
                    {
                        string fileName = await UploadFile.UploadAsync(fileLocation, item);

                        images.Add($@"{UploadFolder}\{CaseFolder}\{fileName}");
                    }
                    data.ImageString = string.Join("-", images);
                }
                await WorkScope.InsertAsync(data);
            }
        }
Ejemplo n.º 11
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        CaseAdmin _CaseAdmin = new CaseAdmin();
        CaseRequest _CaseList = new CaseRequest();

        //If edit mode then retrieve data first
        if (itemID > 0 )
        {
            _CaseList = _CaseAdmin.GetByCaseID(itemID);

        }

        //Set Null Values
        _CaseList.OwnerAccountID = null;
        _CaseList.CaseOrigin = "admin";
        _CaseList.CreateUser = System.Web.HttpContext.Current.User.Identity.Name;
        _CaseList.CreateDte = System.DateTime.Now;
        _CaseList.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        //Set Values
        _CaseList.Title = txtCaseTitle.Text.Trim();
        _CaseList.Description = txtCaseDescription.Text.Trim();
        _CaseList.EmailID = txtEmailID.Text.Trim();
        _CaseList.FirstName = txtFirstName.Text.Trim();
        _CaseList.LastName = txtLastName.Text.Trim();
        _CaseList.PhoneNumber = txtPhoneNo.Text.Trim();
        _CaseList.CompanyName = txtCompanyName.Text.Trim();

        if (lstAccountList.SelectedValue == "-1")
        {
            _CaseList.AccountID = null;
        }
        else
        {
            _CaseList.AccountID = int.Parse(lstAccountList.SelectedValue);
        }

        if (lstCasePriority.SelectedIndex != -1)
        {
            _CaseList.CasePriorityID = int.Parse(lstCasePriority.SelectedValue);
        }
        if (lstCaseStatus.SelectedValue != null)
        {
            _CaseList.CaseStatusID = int.Parse(lstCaseStatus.SelectedValue);
        }

        bool retval = false;

        if (itemID  > 0)
        {
           retval = _CaseAdmin.Update(_CaseList);
        }
        else
        {
            retval = _CaseAdmin.Add(_CaseList);
        }

        if (retval)
        {
            //redirect to list page
            Response.Redirect("~/admin/secure/sales/cases/list.aspx");
        }
        else
        {
            //display error message
            lblMsg.Text = "An error occurred while updating. Please try again.";
        }
    }