Exemplo n.º 1
0
        public IHttpActionResult PutSecretQuestion(SecretQuestion secretQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(secretQuestion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SecretQuestionExists(secretQuestion.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void OutputSecretQuestion(SecretQuestion valueSet)
 {
     OutputStatusMessage(string.Format("Values in {0}", valueSet.GetType()));
     foreach (var value in Enum.GetValues(typeof(SecretQuestion)))
     {
         OutputStatusMessage(value.ToString());
     }
 }
        private int getSecretQuestionByText()
        {
            SecretQuestion question = new SecretQuestion()
            {
                Question = ddlSecretQuestion.SelectedValue
            };

            return(question.getIdByName());
        }
Exemplo n.º 4
0
        public IHttpActionResult GetSecretQuestion(int id)
        {
            SecretQuestion secretQuestion = db.SecretQuestions.Find(id);

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

            return(Ok(secretQuestion));
        }
Exemplo n.º 5
0
        public IHttpActionResult PostSecretQuestion(SecretQuestion secretQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SecretQuestions.Add(secretQuestion);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = secretQuestion.Id }, secretQuestion));
        }
Exemplo n.º 6
0
        public IHttpActionResult DeleteSecretQuestion(int id)
        {
            SecretQuestion secretQuestion = db.SecretQuestions.Find(id);

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

            db.SecretQuestions.Remove(secretQuestion);
            db.SaveChanges();

            return(Ok(secretQuestion));
        }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["recover"] != null)
     {
         User           user     = (User)Session["recover"];
         SecretQuestion question = new SecretQuestion()
         {
             Id = user.IdSecretQuestion
         };
         if (question.Read())
         {
             lblQuestion.Text = question.Question;
         }
     }
 }
Exemplo n.º 8
0
        public ActionResult EditSecretQuestion(SecretQuestion secretQuestionViewModel)
        {
            try
            {
                var secretQuestion = new SecretQuestion
                {
                    Id       = secretQuestionViewModel.Id,
                    Question = secretQuestionViewModel.Question,
                    Answer   = secretQuestionViewModel.Answer
                };
                ApiConsumer <SecretQuestion> .ConsumePut("SecretQuestions", secretQuestion);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Selectes secret question
        /// </summary>
        /// <param name="userLogin"></param>
        /// <returns></returns>
        public static SecretQuestion GetSecretQuestion(string userLogin)
        {
            int userId  = GetUserId(userLogin);
            var secrets = new SecretQuestion();

            try
            {
                SqlConnection conn = new SqlConnection(Connections.ConnectionString);

                string sql = $"SELECT SecretQuestion, SecretAnswer FROM dbo.UserData WHERE Id=@UserId";

                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            secrets.Question = reader.GetString(0);
                            secrets.Answer   = reader.GetString(1);
                        }
                    }

                    else
                    {
                        MessageBox.Show("Record doesn't exist!");
                    }
                }
            }

            catch (SqlException ex)
            {
                string errorMessage = $"Error: {ex}";
                MessageBox.Show(errorMessage);
            }

            return(secrets);
        }
Exemplo n.º 10
0
        public ActionResult AddSecretQuestion(SecretQuestionViewModel secretQuestionViewModel, int id)
        {
            try
            {
                var secretQuestion = new SecretQuestion
                {
                    Question = secretQuestionViewModel.Question,
                    Answer   = secretQuestionViewModel.Answer
                };

                var voter = ApiConsumer <Voter> .ConsumeGet("Voters", id);

                voter.SecretQuestions.Add(secretQuestion);
                var result = ApiConsumer <Voter> .ConsumePut("Voters", voter);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public void CreateShouldSaveAndDisplayCorrectView()
        {
            //ARRANGE
            var model = new SecretQuestion {
                Name = "School One"
            };

            var logic = new Mock <ISecretQuestionLogic>();

            logic
            .Setup(x => x.Create(It.IsAny <SecretQuestion>()))
            .Verifiable("Should create sercet question");

            var controller = new SecretQuestionsController(logic.Object);

            //ACT
            var result = controller.Create(model) as RedirectToRouteResult;

            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.AreEqual("Index", result.RouteValues["Action"]);
        }
Exemplo n.º 12
0
        private UploadAppSampleDataDictionary GetSampleData()
        {
            var r = new UploadAppSampleDataDictionary
            {
                ApplicationType            = ApplicationType.XKeys(),
                CreditTermAsked            = new[] { CreditTermAskedFrom.Text.Toi(), CreditTermAskedTo.Text.Toi() },
                DepositTermAsked           = new[] { DepositTermAskedFrom.Text.Toi(), DepositTermAskedTo.Text.Toi() },
                CreditLimitAsked           = new[] { CreditLimitAskedFrom.Text.Toi(), CreditLimitAskedTo.Text.Toi() },
                DepositLimitAsked          = new[] { DepositLimitAskedFrom.Text.Toi(), DepositLimitAskedTo.Text.Toi() },
                CardCategory               = CardCategory.XKeys(),
                PaternalNameM              = PaternalNameM.XVals(),
                NameM                      = NameM.XVals(),
                LastNameM                  = LastNameM.XVals(),
                PaternalNameG              = PaternalNameG.XVals(),
                NameG                      = NameG.XVals(),
                LastNameG                  = LastNameG.XVals(),
                IsSecondNameNOTChanged     = IsSecondNameNOTChanged.XKeys(),
                PreviousSecondName         = PreviousSecondName.XVals(),
                PlaceOfBirth               = PlaceOfBirth.XVals(),
                BirthDate                  = new[] { BirthDateFrom.Value, BirthDateTo.Value },
                Gender                     = Gender.XKeys(),
                IssuedOn                   = new[] { IssuedOnFrom.Value, IssuedOnTo.Value },
                IssuePlace                 = IssuePlace.XVals(),
                IssuedBy                   = IssuedBy.XVals(),
                LineCodeKLADR              = LineCodeKLADR.XKeys(),
                Building                   = new[] { BuildingFrom.Text.Toi(), BuildingTo.Text.Toi() },
                DeliveryAddress            = DeliveryAddress.XKeys(),
                AccountName                = AccountName.XVals(),
                AccountType                = AccountType.XKeys(),
                LaborContractType          = LaborContractType.XKeys(),
                TotalWorkExperience        = TotalWorkExperience.XKeys(),
                LastSeniority              = LastSeniority.XKeys(),
                JobTitle                   = JobTitle.XKeys(),
                AverageMonthlyIncome       = new[] { AverageMonthlyIncomeFrom.Text.Toi(), AverageMonthlyIncomeTo.Text.Toi() },
                IncomeCheckStatus          = IncomeCheckStatus.XKeys(),
                DeliveryAddressV           = DeliveryAddressV.XKeys(),
                Education                  = Education.XKeys(),
                MaritalStatus              = MaritalStatus.XKeys(),
                MinorChildrenNummber       = MinorChildrenNummber.XKeys(),
                ContactName                = ContactName.XVals(),
                RelationDegree             = RelationDegree.XKeys(),
                IsNotPublicPerson          = IsNotPublicPerson.XKeys(),
                MaidenName                 = MaidenName.XVals(),
                SecretQuestion             = SecretQuestion.XKeys(),
                PreviousCreditsQuantity    = PreviousCreditsQuantity.XKeys(),
                AccountSphere              = AccountSphere.XKeys(),
                AccountCompanyEmployeesQty = AccountCompanyEmployeesQty.XVals(),
                SecretWord                 = SecretWord.XVals(),
                BankingServiceCredit       = BankingServiceCredit.XKeys(),
                BankingServiceDebit        = BankingServiceDebit.XKeys(),
                CurrencyAsked              = CurrencyAsked.XKeys(),
                IsAgreeAuthorityTransfer   = IsAgreeAuthorityTransfer.XKeys(),
                IsDataAuthentic            = IsDataAuthentic.XKeys(),
                Street                     = Street.XVals(),
                PercentPayment             = PercentPayment.XVals(),
                PercentPaymentMethod       = PercentPaymentMethod.XVals(),
                DependentsNumber           = DependantsNumber.XKeys(),
                EarlierCreditStatuse       = EarlierCreditStatuse.XKeys(),
                EarlierCreditType          = EarlierCreditType.XKeys(),
                EarlierBank                = EarlierBank.XKeys(),
                EarlierMaxLoanTerm         = EarlierMaxLoanTerm.XKeys(),
                ClientType                 = ClientType.XKeys(),
            };

            return(r);
        }