示例#1
0
        /// <summary>
        /// Invoked by repair executor
        /// </summary>
        public async Task RequestRepairAsync(Guid activityId, RepairRequest repairRequest, CancellationToken cancellationToken)
        {
            repairRequest.Validate("repairRequest");

            var policyAgentRequest = new PolicyAgentRequest
            {
                RepairRequest = repairRequest
            };

            await PostPolicyAgentRequestAsync(activityId, policyAgentRequest, cancellationToken).ConfigureAwait(false);
        }
 public async Task <object> CreateRepair(RepairRequest request)
 {
     if (request.WorkOrders != null)
     {
         return(await CreateRepairWithOrder(request));
     }
     else
     {
         return(await CreateRepairWithoutOrder(request));
     }
 }
        public void creating_a_repair_request_object_is_successful_if_the_request_priority_code_is_valid()
        {
            var mockLogger = new Mock <ILoggerAdapter <RepairsActions> >();
            var request    = new RepairRequest()
            {
                ProblemDescription = "tap leaking",
                Priority           = "N",
                PropertyReference  = "123456890"
            };

            Assert.Equal("N", request.Priority);
        }
        public async Task return_json_object_for_successful_creation_request_with_orders()
        {
            var request = new RepairRequest
            {
                ProblemDescription = "tap leaking",
                Priority           = "N",
                PropertyReference  = "00000320",
                Contact            = new RepairRequestContact
                {
                    Name            = "Al Smith",
                    TelephoneNumber = "07876543210",
                    EmailAddress    = "*****@*****.**",
                    CallbackTime    = "8am - 12pm"
                },
                WorkOrders = new List <WorkOrder>
                {
                    new WorkOrder
                    {
                        SorCode = "20040020"
                    }
                }
            };

            StringBuilder responsejson = new StringBuilder();

            responsejson.Append("{");
            responsejson.Append("\"repairRequestReference\":\"123456\",");
            responsejson.Append("\"propertyReference\":\"00000320\",");
            responsejson.Append("\"problemDescription\":\"tap leaking\",");
            responsejson.Append("\"priority\":\"N\",");
            responsejson.Append("\"contact\":");
            responsejson.Append("{");
            responsejson.Append("\"name\":\"Al Smith\",");
            responsejson.Append("\"telephoneNumber\":\"07876543210\"");
            responsejson.Append("},");
            responsejson.Append("\"workOrders\":[");
            responsejson.Append("{");
            responsejson.Append("\"workOrderReference\":\"987654\",");
            responsejson.Append("\"sorCode\":\"20090190\",");
            responsejson.Append("\"supplierReference\":\"000000127\"");
            responsejson.Append("}]");
            responsejson.Append("}");

            var requestJson = JsonConvert.SerializeObject(request);

            _client.DefaultRequestHeaders.Accept.Clear();
            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var response = await _client.PostAsync("v1/repairs", new StringContent(requestJson, Encoding.UTF8, "application/json"));

            var responseString = await response.Content.ReadAsStringAsync();

            Assert.Equal(responsejson.ToString(), responseString);
        }
示例#5
0
        /// <summary>
        /// RequestMaintenance:[RoleInstanceName]:[RepairActionTypeEnum][:optional Reason]
        /// E.g.
        /// RequestMaintenance:ServiceFabricRole_IN_2:Reboot:mitigating_incident_123456
        /// </summary>
        private async Task <string> HandleCommandRequestMaintenanceAsync(string args)
        {
            traceType.WriteInfo("Requesting maintenance. Input: {0}", args);

            string[] tokens = args.Split(CommandTokenDelimiter, 3);
            if (tokens.Length < 2)
            {
                throw new ArgumentException("Invalid command arguments");
            }

            string roleInstanceName = tokens[0];

            RepairActionTypeEnum action;

            if (!Enum.TryParse(tokens[1], out action))
            {
                throw new ArgumentException("Invalid command arguments");
            }

            var activityId = Guid.NewGuid();

            // Bond doesn't like a null value for RepairRequest.Reason
            string reason = tokens.Length >= 3 ? reason = tokens[2] : string.Empty;

            try
            {
                var repairRequest = new RepairRequest
                {
                    RoleInstanceId = roleInstanceName,
                    ContextId      = activityId.ToString(),
                    Action         = action,
                    Reason         = reason
                };

                string requestJson = repairRequest.ToJson();

                traceType.WriteInfo("Requesting maintenance. {0}", requestJson);
                await policyAgentClient.RequestRepairAsync(activityId, repairRequest, CancellationToken.None).ConfigureAwait(false);

                traceType.WriteInfo("Successfully requested maintenance. {0}", requestJson);
                return(requestJson);
            }
            catch (ManagementException)
            {
                traceType.WriteWarning(
                    "Error in management protocol while requesting maintenance of role instance: {0} with action: {1} and reason: {2}",
                    roleInstanceName,
                    action,
                    reason);

                throw;
            }
        }
        public async Task <ActionResult <RepairRequest> > SubmitNewRequest([FromBody] RepairRequest newRepairRequest)
        {
            if (ModelState.IsValid)
            {
                await _unitOfWork.Repository <RepairRequest>().AddAsync(newRepairRequest);

                if (await _unitOfWork.Repository <RepairRequest>().SaveAllAsync())
                {
                    return(Ok(newRepairRequest));
                }
            }

            return(BadRequest("failed to submit your repair request"));
        }
示例#7
0
        public void returns_false_and_errormessage_if_repair_request_contains_empty_Property_reference()
        {
            var request = new RepairRequest
            {
                Priority           = "N",
                ProblemDescription = "tap leaking",
                PropertyReference  = ""
            };
            var repairRequestValidator = new RepairRequestValidator();
            var result = repairRequestValidator.Validate(request);

            Assert.False(result.Valid);
            Assert.Equal(result.ErrorMessages.Count, 2);
            Assert.Contains("You must provide a Property reference", result.ErrorMessages);
        }
示例#8
0
        public void returns_false_and_errormessage_if_repair_request_contains_invalid_Priority()
        {
            var request = new RepairRequest
            {
                Priority           = "Q",
                ProblemDescription = "tap leaking",
                PropertyReference  = "12345678"
            };
            var repairRequestValidator = new RepairRequestValidator();
            var result = repairRequestValidator.Validate(request);

            Assert.False(result.Valid);
            Assert.Equal(result.ErrorMessages.Count, 2);
            Assert.Contains("Please provide a valid Priority", result.ErrorMessages);
        }
        public async Task <string> CreateAsync(DateTime date, string description, string userId)
        {
            var requestRepair = new RepairRequest
            {
                Date        = date,
                Description = description,
                UserId      = userId,
            };

            await this.requestRepairRepository.AddAsync(requestRepair);

            await this.requestRepairRepository.SaveChangesAsync();

            return(userId);
        }
示例#10
0
 public static void ServiceBusFighterRepairEventsFunc(
     [ServiceBusTrigger("%serviceBusTopicName%", "%serviceBusFighterSubscription%",
                        AccessRights.Manage,
                        Connection = "serviceBus")] RepairRequest message,
     TraceWriter log)
 {
     try
     {
         log.Error($"Repair Request. Class: {message.ShipClass} \r\n {MessageUtility.GetShipAscii(message.ShipClass)} ");
     }
     catch (Exception ex)
     {
         log.Error(ex.ToString());
     }
 }
 public NewRepairRequest BuildNewRepairRequest(RepairRequest request)
 {
     return(new NewRepairRequest
     {
         RepairRequest = new RepairRequestInfo
         {
             Problem = request.ProblemDescription,
             Priority = request.Priority,
             PropertyRef = request.PropertyReference,
             Name = request.Contact.Name,
             Phone = request.Contact.TelephoneNumber
         },
         DirectUser = GetUserCredentials(),
         SourceSystem = GetUhSourceSystem()
     });
 }
        public void Update(RepairRequest repairRequest)
        {
            using (var db = new RepTecUnitOfWork())
            {
                var status = db.RepairStatusesRepository.GetByСondition(s => s.Id == repairRequest.Status.Id);
                repairRequest.Status = status;

                var equipmentToBeRepaired = db.NomenclatureRepository.GetByСondition(n => n.Id == repairRequest.EquipmentToBeRepaired.Id);
                repairRequest.EquipmentToBeRepaired = equipmentToBeRepaired;

                var repairer = db.RepairersRepository.GetByСondition(r => r.Id == repairRequest.Repairer.Id);
                repairRequest.Repairer = repairer;

                db.RepairRequestsRepository.Update(repairRequest);
                db.Commit();
            }
        }
        public async Task create_repair_raises_an_exception_if_the_repair_request_is_missing()
        {
            var mockLogger    = new Mock <ILoggerAdapter <RepairsActions> >();
            var request       = new RepairRequest();
            var repairRequest = new NewRepairRequest();
            var response      = new RepairCreateResponse {
                Success = true, RepairRequest = null
            };
            var fakeService = new Mock <IHackneyRepairsService>();

            fakeService.Setup(service => service.CreateRepairAsync(It.IsAny <NewRepairRequest>()))
            .ReturnsAsync(response);
            var fakeRequestBuilder = new Mock <IHackneyRepairsServiceRequestBuilder>();

            fakeRequestBuilder.Setup(builder => builder.BuildNewRepairRequest(request)).Returns(repairRequest);
            var repairsActions = new RepairsActions(fakeService.Object, fakeRequestBuilder.Object, mockLogger.Object);
            await Assert.ThrowsAsync <MissingRepairRequestException>(async() => await repairsActions.CreateRepair(request));
        }
        public async Task <ActionResult> Post([FromBody] RepairRequest value)
        {
            if (!IsRiskyJob(value.RepairType))
            {
                _allocationService.AllocateRepair(value);
                return(Ok());
            }

            var user = await _usersService.Get(value.RequestingUserId);

            if (user.UserRoles.Contains(UserRole.RiskAssessor))
            {
                _allocationService.AllocateRepair(value);
                return(Ok());
            }

            return(BadRequest($"User '{value.RequestingUserId}' cannot request risky repairs"));
        }
示例#15
0
        public void returns_true_and_no_error_messages_if_repair_request_contact_contains_no_collback()
        {
            var request = new RepairRequest
            {
                Priority           = "N",
                ProblemDescription = "tap leaking",
                PropertyReference  = "12345678",
                Contact            = new RepairRequestContact
                {
                    Name            = "Al Smith",
                    TelephoneNumber = "07876543210"
                }
            };
            var repairRequestValidator = new RepairRequestValidator();
            var result = repairRequestValidator.Validate(request);

            Assert.True(result.Valid);
            Assert.Equal(result.ErrorMessages.Count, 0);
        }
示例#16
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            RepairRequest = await _context.RepairRequest
                            .Include(m => m.MalfunctionWorkOrder)
                            .ThenInclude(m => m.Instrument)
                            .FirstOrDefaultAsync(m => m.ID == id);

            if (RepairRequest == null)
            {
                return(NotFound());
            }

            var isAuthorized = await _authorizationService.AuthorizeAsync(User, RepairRequest.MalfunctionWorkOrder, Operations.Update);

            if (!isAuthorized.Succeeded)
            {
                return(Forbid());
            }

            // 如果信息已确认或工单已完成则跳转到工单详情页
            if (RepairRequest.IsConfirm || RepairRequest.MalfunctionWorkOrder.Progress == WorkOrderProgress.Completed)
            {
                return(RedirectToPage("../WorkOrders/Details", new { id = RepairRequest.MalfunctionWorkOrderID }));
            }

            if (await TryUpdateModelAsync <RepairRequest>(
                    RepairRequest,
                    "RepairRequest",
                    i => i.RequestTime, i => i.BookingsTime, i => i.Applicant, i => i.Engineer))
            {
                // 更新进度
                if (RepairRequest.MalfunctionWorkOrder.Progress < WorkOrderProgress.RepairRequested)
                {
                    RepairRequest.MalfunctionWorkOrder.Progress = WorkOrderProgress.RepairRequested;
                }

                await _context.SaveChangesAsync();

                return(RedirectToPage("../WorkOrders/Details", new { id = RepairRequest.MalfunctionWorkOrderID }));
            }

            return(Page());
        }
示例#17
0
        public async Task <JsonResult> Post([FromBody] RepairRequest request)
        {
            try
            {
                // Validate the request
                var validationResult = _repairRequestValidator.Validate(request);

                if (validationResult.Valid)
                {
                    RepairsActions actions = new RepairsActions(_repairsService, _requestBuilder, _loggerAdapter);
                    var            result  = await actions.CreateRepair(request);

                    var jsonResponse = Json(result);
                    jsonResponse.StatusCode = 200;
                    return(jsonResponse);
                }
                else
                {
                    var errors = validationResult.ErrorMessages.Select(error => new ApiErrorMessage
                    {
                        developerMessage = error,
                        userMessage      = error
                    }).ToList();
                    var jsonResponse = Json(errors);
                    jsonResponse.StatusCode = 400;
                    return(jsonResponse);
                }
            }
            catch (Exception ex)
            {
                var errors = new List <ApiErrorMessage>
                {
                    new ApiErrorMessage
                    {
                        developerMessage = ex.Message,
                        userMessage      = "We had some problems processing your request"
                    }
                };
                var json = Json(errors);
                json.StatusCode = 500;
                return(json);
            }
        }
        private async Task <object> CreateRepairWithOrder(RepairRequest request)
        {
            _logger.LogInformation($"Creating repair with order (prop ref: {request.PropertyReference})");
            var repairRequest = _requestBuilder.BuildNewRepairTasksRequest(request);

            var response = await _repairsService.CreateRepairWithOrderAsync(repairRequest);

            if (!response.Success)
            {
                throw new RepairsServiceException();
            }
            var workOrderList = response.WorksOrderList;

            if (workOrderList == null)
            {
                throw new MissingRepairRequestException();
            }
            var workOrderItem = workOrderList.FirstOrDefault();

            // update the request status to 000
            _repairsService.UpdateRequestStatus(workOrderItem.RepairRequestReference.Trim());

            var repairTasksResponse = await GetRepairTasksList(workOrderItem.RepairRequestReference);

            var tasksList = repairTasksResponse.TaskList;

            return(new
            {
                repairRequestReference = workOrderItem.RepairRequestReference.Trim(),
                propertyReference = workOrderItem.PropertyReference.Trim(),
                problemDescription = request.ProblemDescription.Trim(),
                priority = request.Priority.Trim(),
                contact = new { name = request.Contact.Name, telephoneNumber = request.Contact.TelephoneNumber },
                workOrders = tasksList.Select(s => new
                {
                    workOrderReference = s.WorksOrderReference.Trim(),
                    sorCode = s.JobCode.Trim(),
                    supplierReference = s.SupplierReference.Trim()
                }).ToArray()
            });
        }
示例#19
0
        public void returns_true_if_repair_request_is_valid()
        {
            var request = new RepairRequest
            {
                Priority           = "N",
                ProblemDescription = "tap leaking",
                PropertyReference  = "12345678",
                Contact            = new RepairRequestContact
                {
                    Name            = "Al Smith",
                    TelephoneNumber = "07876543210",
                    EmailAddress    = "*****@*****.**",
                    CallbackTime    = "8am - 12pm"
                }
            };
            var repairRequestValidator = new RepairRequestValidator();
            var result = repairRequestValidator.Validate(request);

            Assert.True(result.Valid);
            Assert.Equal(result.ErrorMessages.Count, 0);
        }
示例#20
0
        public void returns_false_and_errormsg_if_repair_request_contact_contains_invalid_email()
        {
            var request = new RepairRequest
            {
                Priority           = "N",
                ProblemDescription = "tap leaking",
                PropertyReference  = "12345678",
                Contact            = new RepairRequestContact
                {
                    Name            = "Al Smith",
                    TelephoneNumber = "07876543210",
                    EmailAddress    = "al.smithhotmail.com",
                    CallbackTime    = "8am - 12pm"
                }
            };
            var repairRequestValidator = new RepairRequestValidator();
            var result = repairRequestValidator.Validate(request);

            Assert.False(result.Valid);
            Assert.Equal(result.ErrorMessages.Count, 1);
            Assert.Contains("Please enter valid Email address", result.ErrorMessages);
        }
示例#21
0
        public ActionResult Analyze([Bind(Include = "Id,RequestByName,RequestDate,MainSite,SiteSecondary,RequestType,Description,TaskType,Supervisor,SeniorSupervisor,MaxDurationTime")] RequestPlanningViewModel requestPlanningViewModel)
        {
            if (ModelState.IsValid)
            {
                var mainSiteList = new SelectList(new[] { "سایت 1 - مرکزی",
                                                          "سایت 2 - اداری 2",
                                                          "سایت 3 - بازارچه",
                                                          "سایت 4 - کمپ 4",
                                                          "سایت 5 - پایانه بار",
                                                          "سایت 6 - اسکله و بندر",
                                                          "سایت 7 - شیرینو",
                                                          "سایت 8 - کمپ EPC", });
                ViewBag.MainSiteList = mainSiteList;
                var requestType = new SelectList(new[] { "تعميرات", "نصب تجهيزات جديد" });
                ViewBag.RequestType = requestType;
                var taskType = new SelectList(new[] { "برق و دیزل", "تاسیسات و مکانیک عمومی", "برودت و تهویه", "ابنیه" });
                ViewBag.TaskType = taskType;

                RepairRequest repairRequest = _repairRequestService.FindById(requestPlanningViewModel.Id);
                repairRequest.RequestByName    = requestPlanningViewModel.RequestByName;
                repairRequest.RequestDate      = requestPlanningViewModel.RequestDate;
                repairRequest.MainSite         = requestPlanningViewModel.MainSite;
                repairRequest.SiteSecondary    = requestPlanningViewModel.SiteSecondary;
                repairRequest.RequestType      = requestPlanningViewModel.RequestType;
                repairRequest.Description      = requestPlanningViewModel.Description;
                repairRequest.TaskType         = requestPlanningViewModel.TaskType;
                repairRequest.Supervisor       = requestPlanningViewModel.Supervisor;
                repairRequest.SeniorSupervisor = requestPlanningViewModel.SeniorSupervisor;
                repairRequest.MaxDurationTime  = requestPlanningViewModel.MaxDurationTime;
                repairRequest.PlanningTodo     = false;
                repairRequest.TechnitionTodo   = true;

                _uow.SaveChanges();
                return(RedirectToAction("TodoList"));
            }
            return(View(requestPlanningViewModel));
        }
示例#22
0
        // 批准维修申请
        public async Task <IActionResult> OnPostComfirmAsync(int id)
        {
            RepairRequest = await _context.RepairRequest
                            .Include(m => m.MalfunctionWorkOrder)
                            .ThenInclude(m => m.Instrument)
                            .FirstOrDefaultAsync(m => m.ID == id);

            if (RepairRequest == null)
            {
                return(new JsonResult("未找到该记录"));
            }

            var isAuthorized = await _authorizationService.AuthorizeAsync(User, RepairRequest.MalfunctionWorkOrder, Operations.Approve);

            if (!isAuthorized.Succeeded)
            {
                return(new JsonResult("权限不足"));
            }

            if (RepairRequest.Engineer == null || RepairRequest.BookingsTime == null)
            {
                return(new JsonResult("请补充对接工程师信息或预约时间"));
            }

            RepairRequest.IsConfirm = true;

            try
            {
                await _context.SaveChangesAsync();

                return(new JsonResult("维修申请已批准!"));
            }
            catch (Exception ex)
            {
                return(new JsonResult($"维修申请未批准,错误信息:{ex}"));
            }
        }
        public async Task create_repair_raises_an_exception_if_the_service_responds_with_an_error()
        {
            var mockLogger = new Mock <ILoggerAdapter <RepairsActions> >();
            var request    = new RepairRequest
            {
                ProblemDescription = "tap leaking",
                Priority           = "N",
                PropertyReference  = "123456890"
            };
            var repairRequest = new NewRepairRequest();
            var response      = new RepairCreateResponse {
                Success = false, RepairRequest = null
            };
            var fakeService = new Mock <IHackneyRepairsService>();

            fakeService.Setup(service => service.CreateRepairAsync(repairRequest))
            .ReturnsAsync(response);
            var fakeRequestBuilder = new Mock <IHackneyRepairsServiceRequestBuilder>();

            fakeRequestBuilder.Setup(builder => builder.BuildNewRepairRequest(request)).Returns(repairRequest);

            var repairActions = new RepairsActions(fakeService.Object, fakeRequestBuilder.Object, mockLogger.Object);
            await Assert.ThrowsAsync <RepairsServiceException>(async() => await repairActions.CreateRepair(request));
        }
 public RepairRequest StartRepair(int shipid, int dockId)
 {
     RepairRequest component = new RepairRequest();
     component.StartRepairShip(shipid, dockId);
     return component;
 }
 public RepairRequest FinishRepair(int shipid, int dockId)
 {
     RepairRequest component = new RepairRequest();
     component.GetRepairedShip(shipid, dockId);
     return component;
 }
 public RepairRequest InstantRepair(int shipid, int useGold)
 {
     RepairRequest component = new RepairRequest();
     component.InstantRepairShip(shipid, useGold);
     return component;
 }
 private void StartExpand(int isUseGold)
 {
     if (!this.isRequestingServer)
     {
         this.isRequestingServer = true;
         this.expandDock = ServerRequestManager.instance.ExpandRepair(isUseGold);
         this.expandDock.ExpandSuccess += new EventHandler<EventArgs>(this.OnExpandSuccess);
         this.expandDock.ExpandFail += new EventHandler<EventArgs>(this.OnExpandFail);
     }
 }
示例#28
0
 internal void RepairWallet(RepairRequest repairRequest)
 {
     throw new NotImplementedException();
 }
 public void StartRepairShipAtDock(int shipId, int dockId)
 {
     if (!this.isRequestingServer)
     {
         this.isRequestingServer = true;
         this.startRepairShip = ServerRequestManager.instance.StartRepair(shipId, dockId);
         this.startRepairShip.StartRepairShipSuccess += new EventHandler<EventArgs>(this.OnStartRepairShipSuccess);
         this.startRepairShip.StartRepairShipFail += new EventHandler<EventArgs>(this.OnStartRepairShipFail);
     }
 }
示例#30
0
 public static RequestPlanningViewModel MapModelToViewModelRequestPlanning(this RepairRequest entity)
 {
     return(Mapper.Map <RepairRequest, RequestPlanningViewModel>(entity));
 }
 private void InstantRepairShip(int shipId)
 {
     if (!this.isRequestingServer)
     {
         this.isRequestingServer = true;
         this.instantRepairShip = ServerRequestManager.instance.InstantRepair(shipId, 1);
         this.instantRepairShip.InstanceRepairSuccess += new EventHandler<EventArgs>(this.OnInstanctRepairSuccess);
         this.instantRepairShip.InstantRepairFail += new EventHandler<EventArgs>(this.OnInstantRepairFail);
     }
 }
        // POST api/RepairRequests
        public void Post([FromBody] RepairRequest value)
        {
            var repairRequestsService = new RepairRequestsService();

            repairRequestsService.Insert(value);
        }
        // PUT api/RepairRequests/5
        public void Put(int id, [FromBody] RepairRequest value)
        {
            var repairRequestsService = new RepairRequestsService();

            repairRequestsService.Update(value);
        }
 private void ReqGetFinishedShip(int shipId, int dockId)
 {
     if (!this.isRequestingServer)
     {
         this.isRequestingServer = true;
         this.getFinishedShip = ServerRequestManager.instance.FinishRepair(shipId, dockId);
         this.getFinishedShip.GetShipSuccess += new EventHandler<EventArgs>(this.OnGetShipSuccess);
         this.getFinishedShip.GetShipFail += new EventHandler<EventArgs>(this.OnGetShipFail);
     }
 }
示例#35
0
 public RepairRequestValidationResult(RepairRequest request)
 {
     ErrorMessages = new List <string>();
     Valid         = true;
     RepairRequest = request;
 }
示例#36
0
 public static RequestTechnitionViewModel MapModelToViewModelRequestTechnition(this RepairRequest entity)
 {
     return(Mapper.Map <RepairRequest, RequestTechnitionViewModel>(entity));
 }
示例#37
0
        public RepairRequestValidationResult Validate(RepairRequest request)
        {
            var validationResult = new RepairRequestValidationResult(request);

            if (request == null)
            {
                validationResult.Valid = false;
                validationResult.ErrorMessages.Add("Please provide  a valid repair request");
                return(validationResult);
            }
            if (string.IsNullOrWhiteSpace(request.ProblemDescription))
            {
                validationResult.Valid = false;
                validationResult.ErrorMessages.Add("Please provide a valid Problem");
            }
            if (!string.IsNullOrWhiteSpace(request.PropertyReference))
            {
                var propRefPattern = "^[0-9]{8}$";
                if (!Regex.IsMatch(request.PropertyReference, propRefPattern))
                {
                    validationResult.Valid = false;
                    validationResult.ErrorMessages.Add("Please provide a valid Property reference");
                }
            }
            else
            {
                validationResult.Valid = false;
                validationResult.ErrorMessages.Add("You must provide a Property reference");
            }
            var priorityPattern = "^[UGINEZVMuginezvm]{1}$";

            if (!Regex.IsMatch(request.Priority, priorityPattern))
            {
                validationResult.Valid = false;
                validationResult.ErrorMessages.Add("Please provide a valid Priority");
            }

            if (request.WorkOrders != null)
            {
                if (!(request.WorkOrders.Count == 0))
                {
                    foreach (WorkOrder or in request.WorkOrders)
                    {
                        if (!(or.SorCode == null || or.SorCode.Length == 0))
                        {
                            var sorPattern = "^[A-Za-z0-9]{7,8}$";
                            if (!Regex.IsMatch(or.SorCode, sorPattern))
                            {
                                validationResult.Valid = false;
                                validationResult.ErrorMessages.Add("If Repair request has workOrders you must provide a valid sorCode");
                            }
                        }
                        else
                        {
                            validationResult.Valid = false;
                            validationResult.ErrorMessages.Add("If Repair request has workOrders you must provide a sorCode");
                        }
                    }
                }
                else
                {
                    validationResult.Valid = false;
                    validationResult.ErrorMessages.Add("If Repair request has workOrders you must provide a valid sorCode");
                }
            }

            if (request.Contact != null)
            {
                if (request.Contact.Name == null || request.Contact.Name.Length < 1)
                {
                    validationResult.Valid = false;
                    validationResult.ErrorMessages.Add("Contact Name cannot be empty");
                }

                var telephonePattern = "^[0-9]{10,11}$";
                var telephone        = request.Contact.TelephoneNumber.Replace(" ", "");
                if (!Regex.IsMatch(telephone, telephonePattern))
                {
                    validationResult.Valid = false;
                    validationResult.ErrorMessages.Add("Telephone number must contain minimum of 10 and maximum of 11 digits.");
                }
                if (request.Contact.EmailAddress != null && request.Contact.EmailAddress != string.Empty)
                {
                    var emailPattern = @"[A-Za-z][A-Za-z0-9._%-]+[A-Za-z_\-0-9]@[A-Za-z0-9._%-]+(\.[A-Za-z]{2,4}|\.[A-Za-z]{2,3}\.[A-Za-z]{2,3})([,;]?\s*[A-Za-z_-][A-Za-z0-9._%-]+[A-Za-z_\-0-9]@[A-Za-z0-9._%-]+(\.[A-Za-z]{2,4}|\.[A-Za-z]{2,3}\.[A-Za-z]{2,3}))*";
                    var email        = request.Contact.EmailAddress.Replace(" ", "");
                    if (!Regex.IsMatch(email, emailPattern))
                    {
                        validationResult.Valid = false;
                        validationResult.ErrorMessages.Add("Please enter valid Email address");
                    }
                }
            }
            else
            {
                validationResult.Valid = false;
                validationResult.ErrorMessages.Add("Please provide a contact");
            }

            return(validationResult);
        }