Exemplo n.º 1
0
        public async Task <IActionResult> CreateAccount([FromBody] NewAccountModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await this.accountService.CreateAccountAsync(mapper.Map <UserDto>(model), model.Password);

                    if (result.Succeeded)
                    {
                        return(Ok(new { Succeeded = true }));
                    }
                    else
                    {
                        return(BadRequest(new { Errors = result.Errors.Select(e => e.Description) }));
                    }
                }
                var errors = ModelState.SelectMany(x => x.Value.Errors)
                             .Select(e => e.ErrorMessage)
                             .ToList();
                return(BadRequest(new { Errors = errors }));
            }
            catch (Exception exc)
            {
                return(BadRequest(exc));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult RegisterNewUser(NewAccountModel newAccount)
        {
            try
            {
                IUser newUser = accountBusiness.SignUp(new User
                {
                    UserName = newAccount.UserName,
                    Email    = newAccount.Email
                },
                                                       new Credentials
                {
                    Email    = newAccount.Email,
                    Password = newAccount.Password
                });
                //generate access token response
                var accessTokenResponse = GenerateLocalAccessTokenResponse(newUser);

                // Return success with the bearer token for authorized access
                return(Ok(new { token = accessTokenResponse, profile = newUser }));
            }
            catch (UserAlreadyRegisteredException)
            {
                return(BadRequest("A user with this email address is already registered."));
            }
        }
Exemplo n.º 3
0
 public AccountModel()
 {
     Data          = new NewAccountModel();
     Criteria      = new Dictionary <string, string>();
     Results       = new NewAccountResultModel();
     Header        = Resources.ResultsHeader;
     ErrorMessage  = string.Empty;
     ResultMessage = string.Empty;
 }
Exemplo n.º 4
0
        void btn_Click(object sender, EventArgs e)
        {
            CertButton      btn   = (CertButton)sender;
            NewAccountModel model = NewAccountModel.Instance;

            model.CertifiedDomains = new List <DomainData>();
            model.CertifiedDomains.Add(btn.domain);
            this.Enabled = false;
            controller.StartTest(btn.domain);
        }
Exemplo n.º 5
0
        public ActionResult Post(NewAccountModel newAccount)
        {
            if (ModelState.IsValid)
            {
                //TODO: verificar data de nascimento

                //verifica se a senha está correta
                if (newAccount.Password.Length >= 6 && newAccount.Password.Length <= 30)
                {
                    if (newAccount.Password == newAccount.ConfirmPassword)
                    {
                        if (newAccount.BirthDate != null && newAccount.BirthDate.Year < DateTime.Now.Year)
                        {
                            #region
                            /* Quando for usar uma API internamente, faça o clone antes. */
                            var userapi = ClonedContextInstance <API.Controllers.UserController>();
                            var login   = new LoginController();
                            login.NimbusOrganization = this.NimbusOrganization;
                            login.Session            = this.Session;
                            login.Response           = this.Response;

                            var newUser = new Nimbus.Model.ORM.User()
                            {
                                City      = newAccount.City,
                                Country   = newAccount.Country,
                                Email     = newAccount.Email,
                                FirstName = newAccount.FirstName,
                                LastName  = newAccount.LastName,
                                Password  = newAccount.Password,
                                State     = newAccount.State,
                                AvatarUrl = "/images/av130x130/person_icon.png",
                                BirthDate = newAccount.BirthDate
                            };
                            userapi.CreateProfile(newUser);
                            //aqui deveria redirecionar
                            return(login.Post(new LoginModel()
                            {
                                Email = newAccount.Email, Password = newAccount.Password, RedirectURL = "/"
                            }));

                            #endregion
                        }
                    }
                    else //senha confirmada está incorreta.
                    {
                    }
                }
                else
                {
                    //nao tem 6 digitos
                }
            }

            return(Redirect("/login")); //null => model de errro
        }
Exemplo n.º 6
0
        public Task <IActionResult> CreateAccount(NewAccountModel account)
        {
            _accountRepository.AddAccount(new Account
            {
                Title  = account.Name,
                UserId = _authProvider.AuthenticatedUser.Id
            });

            _unitOfWork.SaveChanges();

            return(Task.FromResult <IActionResult>(Ok()));
        }
Exemplo n.º 7
0
        private void OnQuestionChanged(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnQuestionChanged, model);
                return;
            }

            title.Text   = model.CurrentQuestion.Title;
            varA.Checked = varB.Checked = varC.Checked = varD.Checked = false;
            varA.Text    = model.CurrentQuestion.VarA;
            varB.Text    = model.CurrentQuestion.VarB;
            varC.Text    = model.CurrentQuestion.VarC;
            varD.Text    = model.CurrentQuestion.VarD;
            switch (model.CurrentQuestion.Answer)
            {
            case 0: varA.Checked = true; break;

            case 1: varB.Checked = true; break;

            case 2: varC.Checked = true; break;

            case 3: varD.Checked = true; break;

            default: break;
            }

            NextQuestionButton.Enabled     = !model.IsLastQuestionInSet();
            PreviousQuestionButton.Enabled = !model.IsFirstQuestionInSet();

            q1.BackColor     = q2.BackColor = q3.BackColor =
                q4.BackColor = q5.BackColor = Color.White;
            switch (model.CurrentQuestionIndex)
            {
            case 0: q1.BackColor = Color.Lime; break;

            case 1: q2.BackColor = Color.Lime; break;

            case 2: q3.BackColor = Color.Lime; break;

            case 3: q4.BackColor = Color.Lime; break;

            case 4: q5.BackColor = Color.Lime; break;

            default: break;
            }
        }
Exemplo n.º 8
0
        /*
         * Handlers for external events
         */
        #region external_events

        private void OnQuizReceivedFromServer(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((MyAccountController.ExternalEventHandler)
                            OnQuizReceivedFromServer, model);
                return;
            }
            new NewAccountTestView(NewAccountTestView.TAKE_NEW_CERT, this);
        }
Exemplo n.º 9
0
 private void OnCreateAccountInit(NewAccountModel model)
 {
     while (!this.IsHandleCreated)
     {
         ;
     }
     if (this.InvokeRequired)
     {
         this.Invoke((NewAccountController.ExternalEventHandler)
                     OnCreateAccountInit, model);
         return;
     }
     this.Enabled      = true;
     errorMessage.Text = "Talking to server...";
 }
Exemplo n.º 10
0
        public ActionResult NewAccount(NewAccountModel model)
        {
            EventLogHandler Logger      = new EventLogHandler();
            var             sessionUser = Session["Username"] as string;

            string Normal = "";

            if (model.AccountType == "Asset" || model.AccountType == "Liability")
            {
                Normal = "Debit";
            }
            else
            {
                Normal = "Credit";
            }

            if (ModelState.IsValid)
            {
                using (IDbConnection db = new SqlConnection(SqlAccess.GetConnectionString()))
                {
                    string sql = $"Insert into dbo.ChartOfAccounts (AccountNumber, AccountName, " +
                                 "AccountType, NormalSide, OriginalBalance, CurrentBalance, AccountDescription, CreatedBy, Active, DateCreated)" +
                                 "values(@AccountNumber, @AccountName, @AccountType,@NormalSide,@OriginalBalance," +
                                 "@CurrentBalance,@AccountDescription,@CreatedBy,@Active,@Date)";
                    db.Execute(sql, new
                    {
                        AccountNumber      = model.AccountNumber,
                        AccountName        = model.AccountName,
                        AccountType        = model.AccountType,
                        NormalSide         = Normal,
                        OriginalBalance    = model.OriginalBalance,
                        CurrentBalance     = 0,
                        AccountDescription = model.AccountDescription,
                        CreatedBy          = sessionUser,
                        Active             = model.Active,
                        Date = DateTime.Now
                    });
                }


                TempData["Message"] = "A new account was successfully created!";
                Logger.LogAdminCreateAccount(sessionUser, model.AccountName);

                return(RedirectToAction("ChartOfAccounts"));
            }

            return(View("NewAccount", new NewAccountModel()));
        }
Exemplo n.º 11
0
        private void OnDomainsTimeOut(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnDomainsTimeOut, model);
                return;
            }

            status.Text      = "The server is not reachable.";
            tryagain.Visible = true;
        }
Exemplo n.º 12
0
        private void OnStartTest(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnStartTest, model);
                return;
            }

            this.Enabled      = false;
            errorMessage.Text = "Test is in progress...";
            new NewAccountTestView(NewAccountTestView.CREATE_NEW_ACCOUNT, null);
        }
Exemplo n.º 13
0
        private void OnTimeExpired(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnTimeExpired, model);
                return;
            }

            timeLeft.Text  = "00:00";
            timer1.Enabled = false;
            MessageBox.Show("Time expired.", "REACH");
            controller.FinishQuizSet();
        }
Exemplo n.º 14
0
        private void OnTimeOut(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnTimeOut, model);
                return;
            }

            errors            = new Dictionary <string, string>();
            errors["general"] = "The server is not responding. Try again.";
            errorMessage.Text = errors["general"];
            this.Enabled      = true;
        }
Exemplo n.º 15
0
        private void OnDomainsReceived(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnDomainsReceived, model);
                return;
            }

            domains.Items.Clear();
            domains.Items.AddRange(model.AllDomains.ToArray());
            status.Visible              = false;
            tryagain.Visible            = false;
            CreateNewAccountBtn.Enabled = true;
        }
Exemplo n.º 16
0
        private void OnUsernameTaken(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnUsernameTaken, model);
                return;
            }

            errors             = new Dictionary <string, string>();
            errors["username"] = "******";
            errorMessage.Text  = errors["username"];
            mark(username, "username");
            this.Enabled = true;
        }
Exemplo n.º 17
0
        /*
         * Handlers for external events
         */
        #region external_events

        private void OnCreateAccountDeny(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnCreateAccountDeny, model);
                return;
            }

            errors = model.Errors;
            mark(username, "username");
            mark(password, "password");
            mark(confirm, "confirm");
            mark(email, "email");
            mark(domains, "domains");
            NewAccountView_MouseMove(null, null);
        }
Exemplo n.º 18
0
        private void OnLocalVerificationComplete(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnLocalVerificationComplete, model);
                return;
            }

            this.Enabled       = false;
            username.BackColor = NORMAL_COLOR;
            password.BackColor = NORMAL_COLOR;
            confirm.BackColor  = NORMAL_COLOR;
            email.BackColor    = NORMAL_COLOR;
            domains.BackColor  = NORMAL_COLOR;
            errorMessage.Text  = "Talking to server...";
        }
Exemplo n.º 19
0
        /*
         * Handlers for external events
         */
        #region external_events

        private void OnTick(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnTick, model);
                return;
            }

            timeLeft.Text = ConvertToTime(model.RemainingTime);
            if (model.RemainingTime > 10)
            {
                timeLeft.ForeColor = Color.Black;
            }
            else
            {
                timeLeft.ForeColor = Color.Red;
            }
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Create(NewAccountModel model)
        {
            ViewBag.listRoles = _roleManager.Roles.Where(r => r.Name != Roles.Administrator.ToString()).ToList();
            ViewBag.Regencies = _regencyService.GetAll().ToList();
            if (ModelState.IsValid)
            {
                ApplicationUser user = new ApplicationUser
                {
                    UserName        = model.UserName,
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    Gender          = model.Gender,
                    DayOfBirth      = model.DateOfBirth,
                    ProfileImageUrl = "default.jpg",
                    IsActive        = true,
                    EmailConfirmed  = false,
                    MemberSince     = DateTime.Now.Date,
                    PhoneNumber     = model.PhoneNumber,
                    RegencyId       = model.RegencyId
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(user, "Student");

                    StatusMessage = "User Created Successfully. ";
                    return(RedirectToAction(nameof(Index)));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }
            return(View(model));
        }
Exemplo n.º 21
0
        private void OnTestChanged(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnTestChanged, model);
                return;
            }

            // stop the timer
            timer1.Enabled = false;
            timeLeft.Text  = ConvertToTime(60 * NewAccountModel.MINUTES_PER_QUIZ);
            MessageBox.Show("Start the test for: " + model.CurrentQuiz.Domain, "REACH");

            // set the domain
            domain.Text = model.CurrentQuiz.Domain;

            // reset the timer
            timer1.Enabled = true;
        }
Exemplo n.º 22
0
        public static NewAccountResultModel Save(string webApiAddress, NewAccountModel model)
        {
            using (var restClient = new HttpClient())
            {
                restClient.BaseAddress = new Uri(webApiAddress);
                restClient.DefaultRequestHeaders.Accept.Clear();
                restClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var response = restClient.PostAsJsonAsync <NewAccountModel>(string.Format(ApiClientGenericObjectResources.PostRequestUri, ControllerName), model).Result;

                if (response.IsSuccessStatusCode)
                {
                    var newAccountResultModel = response.Content.ReadAsAsync <NewAccountResultModel>().Result;

                    return(newAccountResultModel);
                }
                else
                {
                    var additionalInformation = response.Content.ReadAsStringAsync().Result;

                    throw new ApplicationException(string.Format("{0}{1}", string.Format(ApiClientGenericObjectResources.UnsuccessfulResponseMessage, response.StatusCode.ToString()), additionalInformation));
                }
            }
        }
Exemplo n.º 23
0
        private void OnAllTestsFinished(NewAccountModel model)
        {
            while (!this.IsHandleCreated)
            {
                ;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                            OnAllTestsFinished, model);
                return;
            }

            timer1.Enabled = false;

            if (type == TAKE_NEW_CERT)
            {
                int score = model.GetScoreForTest(0);

                if (score >= NewAccountModel.MIN_PASSING_SCORE)
                {
                    MessageBox.Show(
                        "You obtained " + score + " points and received the certification for the domain!",
                        "REACH");
                    controller.TakeNewCert(model.CertifiedDomains[0], score);
                }
                else
                {
                    MessageBox.Show(
                        "You didn't pass the test and did not received the certification. You may try again.",
                        "REACH");
                }

                parentForm.Close();
                this.Close();
                return;
            }

            testContainer.Visible    = false;
            resultsContainer.Visible = true;
            int passed = 0;

            for (int i = 0; i < model.CertifiedDomains.Count; ++i)
            {
                // rating control
                RatingControl r = new RatingControl();
                r.Location = new Point(89, 99 + i * (r.Height + 1));
                r.Rating   = model.GetScoreForTest(i);
                r.Fixed    = true;
                if (r.Rating >= NewAccountModel.MIN_PASSING_SCORE)
                {
                    ++passed;
                }
                r.Visible = true;
                resultsContainer.Controls.Add(r);

                // the label with the domain
                Label domainTitle = new Label();
                domainTitle.Location = new Point(12, 106 + i * (r.Height + 1));
                domainTitle.Font     = new Font(
                    "Microsoft Sans Serif",
                    9.75F,
                    FontStyle.Regular,
                    GraphicsUnit.Point,
                    ((byte)(0)));
                domainTitle.Text    = model.CertifiedDomains[i].Name + ":";
                domainTitle.Visible = true;
                resultsContainer.Controls.Add(domainTitle);

                // the label with the result
                Label domainStatus = new Label();
                domainStatus.Location = new Point(211, 106 + i * (r.Height + 1));
                domainStatus.Font     = new Font(
                    "Microsoft Sans Serif",
                    9.75F,
                    FontStyle.Bold,
                    GraphicsUnit.Point,
                    ((byte)(0)));
                if (r.Rating >= NewAccountModel.MIN_PASSING_SCORE)
                {
                    domainStatus.ForeColor = Color.Green;
                    domainStatus.Text      = "Passed";
                }
                else
                {
                    domainStatus.ForeColor = Color.Red;
                    domainStatus.Text      = "Failed";
                }
                domainStatus.Visible = true;
                resultsContainer.Controls.Add(domainStatus);
            }
            if (passed > 0)
            {
                resultTitle.Text =
                    "Your account was created. You will receive a certificate for each domain that you passed successfully.";
                controller.CreateAccount();
            }
            else
            {
                resultTitle.Text =
                    "You didn't pass any test. Your account was not created. You may try again.";
            }
        }
        public async Task <HttpResponseMessage> PutAsync([FromBody] NewAccountModel account)
        {
            var result = await _accountApplicationService.UpdateAccountAsync(Mapper.Map <User>(account));

            return(Request.CreateResponse(HttpStatusCode.OK, Mapper.Map <AccountModel>(result)));
        }
Exemplo n.º 25
0
        public ActionResult NewAccount()
        {
            NewAccountModel m = new NewAccountModel();

            return(View(m));
        }
 public NewAccountViewModel(DashboardVM aDashboardVM)
 {
     DashboardVM = aDashboardVM;
     newAccount  = new NewAccountModel("", "", "", "", "", "", "");
     registerNow = new NewAccountCommand(this);
 }
Exemplo n.º 27
0
        /// <summary>
        /// 获取两个时间段拉新数据
        /// </summary>
        /// <param name="stDate"></param>
        /// <param name="edDate"></param>
        /// <param name="lstDate"></param>
        /// <param name="ledDate"></param>
        /// <returns></returns>
        public static NewAccountModel GetNewAccountModel(DateTime stDate, DateTime edDate, DateTime lstDate,
                                                         DateTime ledDate)
        {
            NewAccountModel model = new NewAccountModel();

            DateTime tedDate             = ControlHelper.GetEndDate(edDate);
            List <NewAccountItem> tModel = OperationReportBLL.GetNewAccountModel(stDate, tedDate);

            DateTime ltedDate            = ControlHelper.GetEndDate(ledDate);
            List <NewAccountItem> lModel = OperationReportBLL.GetNewAccountModel(lstDate, ltedDate);

            #region 合并两日数据

            foreach (var item in tModel)
            {
                foreach (var lItem in lModel)
                {
                    if (lItem.SourceName == item.SourceName)
                    {
                        item.LastWeekVal = lItem.ThisWeekVal;
                    }
                }
            }

            #endregion

            #region 数据分组

            List <ItemGroup> itemGroup = new List <ItemGroup>()
            {
                new ItemGroup("iOS", 2, 1),
                new ItemGroup("Android", 10, 1),
                new ItemGroup("主站", 4, 1),
                new ItemGroup("下载站", 1, 2),
                new ItemGroup("其他PC客户端", 1, 2),
                new ItemGroup("来源未知", 1, 2),
                new ItemGroup("总注册", 1, 2)
            };

            itemGroup.Find(x => x.GroupName == "总注册").DataList.Add(new NewAccountItem("总注册", 0, 0));

            itemGroup.Find(x => x.GroupName == "iOS").DataList.Add(new NewAccountItem("iPhone", 0, 0));
            itemGroup.Find(x => x.GroupName == "iOS").DataList.Add(new NewAccountItem("iPad", 0, 0));

            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("360", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("华为", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("小米", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("魅族", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("oppo", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("豌豆荚", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("百度", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("应用宝", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("安智", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("应用宝CPD", 0, 0));
            itemGroup.Find(x => x.GroupName == "Android").DataList.Add(new NewAccountItem("其他", 0, 0));

            itemGroup.Find(x => x.GroupName == "主站").DataList.Add(new NewAccountItem("手机web", 0, 0));
            itemGroup.Find(x => x.GroupName == "主站").DataList.Add(new NewAccountItem("主站安卓", 0, 0));
            itemGroup.Find(x => x.GroupName == "主站").DataList.Add(new NewAccountItem("主站客户端", 0, 0));
            itemGroup.Find(x => x.GroupName == "主站").DataList.Add(new NewAccountItem("主站注册", 0, 0));

            itemGroup.Find(x => x.GroupName == "下载站").DataList.Add(new NewAccountItem("下载站", 0, 0));
            itemGroup.Find(x => x.GroupName == "其他PC客户端").DataList.Add(new NewAccountItem("其他PC客户端", 0, 0));
            itemGroup.Find(x => x.GroupName == "来源未知").DataList.Add(new NewAccountItem("来源未知", 0, 0));

            foreach (var item in tModel)
            {
                itemGroup.Find(x => x.GroupName == "总注册").DataList[0].ThisWeekVal += item.ThisWeekVal;
                itemGroup.Find(x => x.GroupName == "总注册").DataList[0].LastWeekVal += item.LastWeekVal;

                foreach (var gItem in itemGroup)
                {
                    if (gItem.DataList.Find(x => x.SourceName == item.SourceName) != null)
                    {
                        gItem.DataList.Find(x => x.SourceName == item.SourceName).ThisWeekVal = item.ThisWeekVal;
                        gItem.DataList.Find(x => x.SourceName == item.SourceName).LastWeekVal = item.LastWeekVal;
                        gItem.DataList.Find(x => x.SourceName == item.SourceName).Percent     =
                            item.LastWeekVal == 0
                                ? "-"
                                : (Convert.ToDecimal(item.ThisWeekVal - item.LastWeekVal) * 100 / item.LastWeekVal).ToString("F2") +
                            "%";
                    }
                }
            }

            foreach (var item in itemGroup)
            {
                if (item.ColSpan > 1 && item.DataList.Count <= 0)
                {
                    item.GroupName = "Not Support";
                }
                if (item.RowSpan > 1)
                {
                    if (item.DataList.Count <= 0)
                    {
                        item.GroupName = "Not Support";
                    }
                    else
                    {
                        item.RowSpan = item.DataList.Count;
                    }
                }

                foreach (var dItem in item.DataList)
                {
                    if (string.IsNullOrEmpty(dItem.Percent))
                    {
                        if (dItem.LastWeekVal == 0)
                        {
                            dItem.Percent = "-";
                        }
                        else
                        {
                            dItem.Percent = (Convert.ToDecimal(dItem.ThisWeekVal - dItem.LastWeekVal) * 100 / dItem.LastWeekVal).ToString("F2") + "%";
                        }
                    }
                }
            }

            model.ItemGroupList = itemGroup;
            return(model);

            #endregion
        }