Inheritance: IActionCommand
        public IActionResult GetCommunalsByPhoneNumber(SearchCommunalRequest request)
        {
            if (ModelState.IsValid)
            {
                SingleResponse <List <Communal> > response = new SingleResponse <List <Communal> >();
                string validationResult = _xBService.ValidateSearchData(request.SearchCommunal);
                if (validationResult == "")
                {
                    response.Result = _xBService.GetCommunalsByPhoneNumber(request.SearchCommunal);
                }
                else
                {
                    XBS.ActionResult result = new XBS.ActionResult
                    {
                        ResultCode = ResultCode.ValidationError,
                        Errors     = new List <ActionError>()
                    };

                    ActionError actionError = new ActionError();
                    actionError.Description = validationResult;

                    result.Errors.Add(actionError);
                }
                response.ResultCode = ResultCodes.normal;
                return(ResponseExtensions.ToHttpResponse(response));
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }
Esempio n. 2
0
        public List <KeyValuePair <string, string> > GetCommunalBranchList(XBSInfo.CommunalTypes communalType)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();

            if (communalType == (XBSInfo.CommunalTypes) 3 || communalType == (XBSInfo.CommunalTypes) 4 ||
                communalType == (XBSInfo.CommunalTypes) 5 || communalType == (XBSInfo.CommunalTypes) 6 ||
                communalType == (XBSInfo.CommunalTypes) 9)
            {
                this.Use(client =>
                {
                    result = client.GetCommunalBranchListAsync(communalType, XBSInfo.Languages.hy).Result;
                });
            }
            else
            {
                ActionResult res = new ActionResult();
                res.ResultCode = ResultCode.ValidationError;
                res.Errors     = new List <ActionError>();

                ActionError actionError = new ActionError();
                actionError.Description = "Wrong CommunalType";

                res.Errors.Add(actionError);
            }

            return(result.ToList() ?? new List <KeyValuePair <string, string> >());
        }
Esempio n. 3
0
 //action roll back
 public ActionError RollBack(ActionInput input)
 {
     for (int i = 0; i < this.m_vecActions.Length; i++)
     {
         CAction action = ActionManager.sInstance.GetAction(this.m_vecActions[i]);
         if (action != null)
         {
             ActionError error = action.RollBack(input);
             if (error != null && error.code != ACTION_ERROR_CODE.NONE)
             {
                 return(error);
             }
         }
     }
     return(ActionError.NoError);
 }
Esempio n. 4
0
        private List <ActionError> Validate(Planet model)
        {
            var errors = new List <ActionError>();

            if (string.IsNullOrEmpty(model.Name))
            {
                errors.Add(ActionError.NoName(nameof(Planet)));
            }

            if (model.Name.Length > 256)
            {
                errors.Add(ActionError.NameToLong(nameof(Planet)));
            }

            return(errors);
        }
Esempio n. 5
0
        private IEnumerable <ActionError> ValidateRobots(List <Guid> robots, List <Guid> oldRobotsIds)
        {
            var response = new List <ActionError>();

            var sameRobots = robots.Intersect(oldRobotsIds ?? new List <Guid>()).ToList();

            if (sameRobots.Count == 5)
            {
                return(response);
            }

            if (robots.Count != 5)
            {
                response.Add(new ActionError
                {
                    Code        = "5Robots",
                    Description = "There should be exactly 5 robots in the team"
                });
            }

            var newRobots = robots.Except(sameRobots);

            foreach (var robot in newRobots)
            {
                var dbRobot      = _robotService.GetById(robot);
                var errorMessage = $"Robot with id {robot}";
                if (dbRobot == null)
                {
                    response.Add(ActionError.NotFound(errorMessage));
                    continue;
                }

                if (dbRobot.Status != RobotStatus.Unassigned)
                {
                    response.Add(ActionError.NotAvailableForTeam(errorMessage));
                }
            }

            return(response);
        }
Esempio n. 6
0
        private IEnumerable <ActionError> ValidateShuttle(Guid shuttleId, Guid oldShuttleId)
        {
            var response = new List <ActionError>();

            if (oldShuttleId == shuttleId)
            {
                return(response);
            }

            var shuttle = _shuttleService.GetById(shuttleId);

            if (shuttle == null)
            {
                response.Add(ActionError.NotFound("Shuttle"));
            }

            if (shuttle != null && shuttle.Status != ShuttleStatus.Unassigned)
            {
                response.Add(ActionError.NotAvailableForTeam("Shuttle"));
            }

            return(response);
        }
Esempio n. 7
0
        private IEnumerable <ActionError> ValidateCaptain(Guid captainId, Guid oldCaptainId)
        {
            var response = new List <ActionError>();

            if (oldCaptainId == captainId)
            {
                return(response);
            }

            var captain = _captainService.GetById(captainId);

            if (captain == null)
            {
                response.Add(ActionError.NotFound("Captain"));
            }

            if (captain != null && captain.Status != CaptainStatus.Unassigned)
            {
                response.Add(ActionError.NotAvailableForTeam("Captain"));
            }

            return(response);
        }
 private void SetError(string error)
 {
     ActionError?.Invoke(this, error);
 }
Esempio n. 9
0
 public PlayerActionResult(int actionId, ActionError error)
 {
     ActionId = actionId;
     Error    = error;
 }
 public ActionResult(ActionError error) : base(error)
 {
 }
Esempio n. 11
0
 protected virtual void OnActionError(string filename, string actionName, System.Exception error)
 {
     ActionError?.Invoke(this, new XCOMActionErrorEventArgs(filename, actionName, error));
 }