Exemplo n.º 1
0
        private void button27_Click(object sender, EventArgs e)
        {
            var spApp = new ApplicationProcessor(ConfigurationManager.AppSettings["SPStoragePath"]);

            MessageBox.Show(
                spApp.Delete(spApp.Gets().FirstOrDefault().Id).ToString()
                );

            dgv.DataSource = spApp.Gets().ToDataTable();
        }
Exemplo n.º 2
0
        private void button24_Click(object sender, EventArgs e)
        {
            var spApp = new ApplicationProcessor(ConfigurationManager.AppSettings["SPStoragePath"]);

            MessageBox.Show(
                spApp.Insert(new ApplicationsModel
            {
                Id               = new Guid(),
                Name             = "Test App",
                ConnectionString = "Contoh ConnectionString",
                IsActive         = true
            }).ToString()
                );

            dgv.DataSource = spApp.Gets().ToDataTable();
        }
        public IActionResult CardApplication([Bind("FirstName,LastName,Dob,AnnualIncome")] CardApplicationViewModel cardApplication)
        {
            if (!ModelState.IsValid)
            {
                return(View("CardApplication", cardApplication));
            }

            var applicationProcessor = new ApplicationProcessor(_dateTimeHelper);

            var validAge = applicationProcessor.ValidateAge(cardApplication.Dob);

            if (!validAge)
            {
                var under18Result = new ApplicationResult
                {
                    FirstName = cardApplication.FirstName,
                    LastName  = cardApplication.LastName,
                    Result    = "No cards shown"
                };
                _context.ApplicationResults.Add(under18Result);
                _context.SaveChanges();

                return(View("AgeNotValid"));
            }

            var card       = applicationProcessor.ProcessApplication(cardApplication.AnnualIncome);
            var cardResult = new ApplicationResult
            {
                FirstName = cardApplication.FirstName,
                LastName  = cardApplication.LastName,
                Result    = "Card shown: " + card.CardName
            };

            _context.ApplicationResults.Add(cardResult);
            _context.SaveChanges();

            return(View("CardOffer", card));
        }
Exemplo n.º 4
0
        private static void AssertResult(string path, bool?flagState, bool executionState)
        {
            var result = ApplicationProcessor.NeedWaitForProcess(flagState, path);

            Assert.AreEqual(executionState, result);
        }
Exemplo n.º 5
0
 public IActionResult BookedTicketList([FromBodyAttribute] BookedTicketFilter filter)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Ok(new Application_ResponseWrapper()
             {
                 ResponseCode = "1000", ResponseMessage = "Invalid model", Status = "failed"
             }));
         }
         using (IApplicationProcessor _processor = new ApplicationProcessor(_applicationDbContext))
         {
             string pagesSize = _processor.GetApplicationSettingByKey("displayList_Count");
             if (!string.IsNullOrEmpty(pagesSize) || int.Parse(Convert.ToString(pagesSize)) <= 0)
             {
                 filter.pages = int.Parse(pagesSize);
             }
             else
             {
                 _errorRepository.Add(new Application_Errors
                 {
                     applicationID    = 1,
                     errorDescription = "Page size value not found.",
                     errorType        = "Log",
                     logDate          = System.DateTime.Now,
                     pageID           = 0,
                     Source           = "Mpower/Rail/History/Ticket/List"
                 });
                 _errorRepository.Commit();
                 return(Ok(new Application_ResponseWrapper()
                 {
                     ResponseCode = "1013", ResponseMessage = "Page Size is not found!", Status = "failed"
                 }));
             }
         }
         using (ITicketProcessor _ticketProcessor = new TicketProcessor(_applicationDbContext))
         {
             var list = _ticketProcessor.BookedTicketList(filter);
             if (list == null || list.Count == 0)
             {
                 return(Ok(new Application_ResponseWrapper()
                 {
                     ResponseCode = "1004", ResponseMessage = "Record not found", Status = "failed"
                 }));
             }
             return(Ok(new Application_ResponseWrapper()
             {
                 ResponseCode = "0", ResponseMessage = "success", Status = "success", ResponseResult = list
             }));
         }
     }
     catch (Exception ex)
     {
         _errorRepository.
         Add(new Application_Errors
         {
             applicationID    = 1,
             errorDescription = ex.StackTrace,
             errorType        = "Exception",
             logDate          = System.DateTime.Now,
             pageID           = 0,
             Source           = "Mpower/Rail/History/Ticket/List"
         });
         _errorRepository.Commit();
         return(Ok(new Application_ResponseWrapper()
         {
             ResponseCode = "1005", ResponseMessage = "An error has occured", Status = "failed"
         }));
     }
 }
Exemplo n.º 6
0
        public IActionResult CreateUser([FromBody] Mpower.Rail.Model.Request.UserRegistration userDetail)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (IApplicationProcessor _processor = new ApplicationProcessor(_applicationDbContext))
                    {
                        string pattern = _processor.GetPasswordRegularExpression();
                        if (!string.IsNullOrEmpty(pattern))
                        {
                            Regex regex = new Regex(pattern);
                            if (!regex.IsMatch(userDetail.password))
                            {
                                return(Ok(new Application_ResponseWrapper()
                                {
                                    ResponseCode = "1010", ResponseMessage = "Password not validated!", Status = "failed"
                                }));
                            }
                        }
                        else
                        {
                            _errorRepository.
                            Add(new Application_Errors
                            {
                                applicationID    = 1,
                                errorDescription = "Password regular expression not found.",
                                errorType        = "Log",
                                logDate          = System.DateTime.Now,
                                pageID           = 0,
                                Source           = "Mpower/Rail/UserRegistration/Create"
                            });
                            _errorRepository.Commit();
                            return(Ok(new Application_ResponseWrapper()
                            {
                                ResponseCode = "1010", ResponseMessage = "Password not validated!", Status = "failed"
                            }));
                        }
                    }

                    UserRegistration _userDetail = null;

                    using (IUserProcessor _userProcessor = new UserProcessor(_applicationDbContext))
                    {
                        if (_userProcessor.UserExists(userDetail.email))
                        {
                            return(Ok(new Application_ResponseWrapper()
                            {
                                ResponseCode = "1012", ResponseMessage = "Email already registered!", Status = "failed"
                            }));
                        }
                        if (_userProcessor.UserCredentialExists(userDetail.subUserId, userDetail.subUserPassword, userDetail.merchantId, userDetail.merchantAccount))
                        {
                            return(Ok(new Application_ResponseWrapper()
                            {
                                ResponseCode = "1011", ResponseMessage = "User already registered!", Status = "failed"
                            }));
                        }
                        _userDetail = _userProcessor.RegisterAgent(userManager: _userManager, userDetail: userDetail);
                    }
                    return(Ok(new Application_ResponseWrapper()
                    {
                        ResponseCode = "0", ResponseMessage = "success", Status = "success", ResponseResult = _userDetail
                    }));
                }
                else
                {
                    return(Ok(new Application_ResponseWrapper()
                    {
                        ResponseCode = "1000", ResponseMessage = "Invalid model", Status = "failed"
                    }));
                }
            }
            catch (Exception ex)
            {
                _errorRepository.
                Add(new Application_Errors
                {
                    applicationID    = 1,
                    errorDescription = ex.StackTrace,
                    errorType        = "Exception",
                    logDate          = System.DateTime.Now,
                    pageID           = 0,
                    Source           = "Mpower/Rail/UserRegistration/Create"
                });
                _errorRepository.Commit();
                return(Ok(new Application_ResponseWrapper()
                {
                    ResponseCode = "1005", ResponseMessage = "An error has occured", Status = "failed"
                }));
            }
        }