예제 #1
0
        private async Task <KeypadModel> FixButtonsAsync(long stateId, object myObject)
        {
            var keypad = new KeypadModel();

            if (stateId == 1)
            {
                var isCompleted = true;

                keypad = await GetKeypadAsync(1);

                var info = (UserInfoEntity)myObject;

                if (!string.IsNullOrEmpty(info.FirstName))
                {
                    SetImage(keypad, "1-1");
                }
                else
                {
                    isCompleted = false;
                }

                if (!string.IsNullOrEmpty(info.LastName))
                {
                    SetImage(keypad, "1-2");
                }
                else
                {
                    isCompleted = false;
                }

                if (info.ProvinceId.HasValue)
                {
                    SetImage(keypad, "1-3");
                }
                else
                {
                    isCompleted = false;
                }

                if (info.CityId.HasValue)
                {
                    SetImage(keypad, "1-4");
                }
                else
                {
                    isCompleted = false;
                }

                if (info.PopulationStatus.HasValue)
                {
                    SetDefaultValue(keypad, "1-5", EnumValue.GetEnumValue(info.PopulationStatus.Value));
                    SetImage(keypad, "1-5");
                }
                else
                {
                    SetDefaultValue(keypad, "1-5", "شهرستان");
                    isCompleted = false;
                }

                if (!string.IsNullOrEmpty(info.Mobile))
                {
                    SetImage(keypad, "1-6");
                }
                else
                {
                    isCompleted = false;
                }

                if (!isCompleted)
                {
                    SetAlert(keypad, "1-submit");
                }
            }


            if (stateId == 2)
            {
                var isCompleted = true;

                keypad = await GetKeypadAsync(2);

                var info = (UserInfoEntity)myObject;

                if (!string.IsNullOrEmpty(info.Address))
                {
                    SetImage(keypad, "2-1");
                }
                else
                {
                    isCompleted = false;
                }

                if (!string.IsNullOrEmpty(info.PostalCode))
                {
                    SetImage(keypad, "2-2");
                }
                else
                {
                    isCompleted = false;
                }

                if (!string.IsNullOrEmpty(info.BirthDate))
                {
                    SetDefaultValue(keypad, "2-3", info.BirthDate);
                    SetImage(keypad, "2-3");
                }
                else
                {
                    var    time = DateTime.Now;
                    string now  = "" + time.Year + time.Month + time.Day;
                    isCompleted = false;
                    SetDefaultValue(keypad, "2-3", now);
                    isCompleted = false;
                }

                if (!string.IsNullOrEmpty(info.NationalCode))
                {
                    SetImage(keypad, "2-4");
                }
                else
                {
                    isCompleted = false;
                }

                if (info.PositionType.HasValue)
                {
                    SetDefaultValue(keypad, "2-5", EnumValue.GetEnumValue(info.PositionType.Value));
                    SetImage(keypad, "2-5");
                }
                else
                {
                    isCompleted = false;
                }

                if (!isCompleted)
                {
                    SetAlert(keypad, "2-submit");
                }
            }


            if (stateId == 3)
            {
                var isCompleted = true;

                keypad = await GetKeypadAsync(3);

                var info = (UserInfoEntity)myObject;

                if (!string.IsNullOrEmpty(info.VideoSrc))
                {
                    SetImage(keypad, "3-1");
                }
                else
                {
                    isCompleted = false;
                }

                if (!isCompleted)
                {
                    SetAlert(keypad, "3-submit");
                }
            }

            return(keypad);
        }