Ejemplo n.º 1
0
        private async Task <IList <ErrorDTO> > ValidateModel(AgencyUpdateRequest req)
        {
            var result         = new List <ErrorDTO>();
            var existingRecord = await _repos.GetAgencyByAgencyNameAsync(req.Agency.Name);

            if (existingRecord != null)
            {
                if (req.Agency.Id <= 0)
                {
                    result.Add(new ErrorDTO {
                        ErrorMsg = "Duplicate Case Type Detected."
                    });
                }
                else if (req.Agency.Id > 0 && existingRecord != null && existingRecord.Id != req.Agency.Id)
                {
                    result.Add(new ErrorDTO {
                        ErrorMsg = "Duplicate Case Type Detected."
                    });
                }
            }
            if (string.IsNullOrWhiteSpace(req.Agency.Name))
            {
                result.Add(new ErrorDTO {
                    ErrorMsg = "Office Name is Required"
                });
            }
            if (!string.IsNullOrWhiteSpace(req.Agency.Name) && req.Agency.Name.Length > 100)
            {
                result.Add(new ErrorDTO {
                    ErrorMsg = "Office Name is limitted to 100 characters."
                });
            }
            return(result);
        }