コード例 #1
0
ファイル: ManagedService.cs プロジェクト: qwdf1615/sncore
        protected virtual ManagedQuota GetQuota(ManagedSecurityContext sec)
        {
            // check whether the default quota was overridden
            IQuery query = Session.CreateQuery(string.Format(
                                                   "FROM AccountQuota AccountQuota WHERE AccountQuota.Account.Id = {0} AND AccountQuota.DataObject.Name = '{1}'",
                                                   sec.Account.Id, typeof(DatabaseType).Name));

            AccountQuota q = query.UniqueResult <AccountQuota>();

            if (q != null)
            {
                return(new ManagedQuota(q.Limit));
            }

            return(ManagedQuota.GetDefaultEnabledQuota());
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            string             reply_str      = "";
            var                db             = new EchoContext();
            SmsRegistrationLog sms_log        = new SmsRegistrationLog();
            string             sms_log_result = "";

            try
            {
                string keyword   = context.Request.Form["keyword"] == null ? string.Empty : context.Request.Form["keyword"];
                string content   = context.Request.Form["content"] == null ? string.Empty : context.Request.Form["content"];
                string mobile_no = context.Request.Form["mobile_no"] == null ? string.Empty : context.Request.Form["mobile_no"];
                //string msg = context.Request.Form["msg"] == null ? string.Empty : context.Request.Form["msg"];


                sms_log.Mobile_Number = mobile_no;
                sms_log.RQ_Msg        = "-";
                sms_log.RQ_Keyword    = keyword;
                sms_log.RQ_Content    = content;


                int  result = CustomValidate.ValidateNumber(mobile_no);
                bool flag   = true;

                if (result != 1 && result != 4)
                {
                    flag = false;
                    if (result == 2 || result == 3 || result == 5)
                    {
                        reply_str      = System.Configuration.ConfigurationManager.AppSettings["EXIST_NUMBER"];
                        sms_log_result = "Existing number";
                    }

                    if (result == 6)
                    {
                        reply_str      = System.Configuration.ConfigurationManager.AppSettings["NO_ACCTACTIVATION"];
                        sms_log_result = "Maintenance Period";
                    }
                }

                if (flag)
                {
                    if (IsValid(keyword, content))
                    {
                        string[] content_arrs = content.Split(' ');
                        string   gender       = content_arrs[0];
                        string   dob          = content_arrs[1];
                        string[] result_sp    = new string[2];

                        byte day   = Convert.ToByte(dob.Substring(0, 2));
                        byte month = Convert.ToByte(dob.Substring(2, 2));
                        int  year  = Convert.ToInt16(dob.Substring(4, 4));

                        year = year - 543;
                        #region transaction
                        var transactionOptions = new TransactionOptions();
                        transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
                        transactionOptions.Timeout        = TransactionManager.MaximumTimeout;
                        Account  account   = new Account();
                        DateTime timestamp = DateTime.Now;
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
                        {
                            var db_transaction = new EchoContext();

                            account.Gender_Cd           = gender.ToUpper();
                            account.Day_Of_Birth        = day;
                            account.Month_Of_Birth      = month;
                            account.Year_Of_Birth       = year;
                            account.Channel_Cd          = "SMS";
                            account.Created_By          = System.Configuration.ConfigurationManager.AppSettings["CREATED_BY_SMS"];
                            account.Updated_By          = System.Configuration.ConfigurationManager.AppSettings["CREATED_BY_SMS"];
                            account.First_Mobile_Number = mobile_no;
                            account.Created_Dttm        = timestamp;
                            account.Updated_Dttm        = timestamp;
                            account.Registration_Dttm   = timestamp;

                            var   today = DateTime.Now.Date;
                            Quota q     = db_transaction.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).Where(x => x.Quota_Cd.Equals("Q0001")).SingleOrDefault();

                            #region account quota used cur
                            AccountQuotaUsedCur aquc = new AccountQuotaUsedCur();
                            aquc.Date                = today.Date;
                            aquc.Account             = account;
                            aquc.Quota_Freq_Used_Val = 0;
                            aquc.Quota_Avail_Flag    = true;
                            aquc.Quota_Dur_Val       = Convert.ToByte(q.Quota_Dur_Val);
                            aquc.Quota_Freq_Val      = Convert.ToByte(q.Quota_Freq_Val);
                            db_transaction.AccountQuotaUsedCurs.Add(aquc);
                            #endregion

                            #region account mobile
                            AccountMobile am = new AccountMobile();
                            am.Account       = account;
                            am.Mobile_Number = mobile_no;
                            am.Primary_Flag  = true;
                            am.Status_Cd     = "AC";
                            am.Updated_By    = System.Configuration.ConfigurationManager.AppSettings["CREATED_BY_SMS"];
                            am.Created_By    = System.Configuration.ConfigurationManager.AppSettings["CREATED_BY_SMS"];
                            db_transaction.AccountMobiles.Add(am);
                            #endregion

                            #region account interest
                            AccountInterest ai = new AccountInterest();
                            ai.Account = account;
                            db_transaction.AccountInterests.Add(ai);
                            #endregion

                            #region account quota
                            AccountQuota aq = new AccountQuota();
                            aq.Account  = account;
                            aq.Quota_Cd = q.Quota_Cd;
                            db_transaction.AccountQuotas.Add(aq);
                            #endregion

                            #region update account activation and set status_cd
                            SqlParameter output = new SqlParameter("acstatus", SqlDbType.Int);
                            output.Direction = ParameterDirection.Output;

                            SqlParameter date = new SqlParameter("today", SqlDbType.Date);
                            date.Value = DateTime.Now;

                            SqlParameter no_acct_total = new SqlParameter("no_acct_limit_total", SqlDbType.Int);

                            int no_acct_limit_total         = 0;
                            AdminConfiguration admin_config = db_transaction.AdminConfigurations.SingleOrDefault();

                            if (admin_config != null)
                            {
                                no_acct_limit_total = admin_config.No_Activation_Limit_Total;
                            }

                            no_acct_total.Value = no_acct_limit_total;
                            string sql_string =
                                "declare @tbt table (acstatus int)" +
                                "UPDATE Account_Activation " +
                                "SET No_Activation = CASE WHEN (No_Activation + 1 > No_Max_Activation or (No_Activation_Acc + 1 > @no_acct_limit_total)) THEN No_Activation ELSE No_Activation + 1 END, " +
                                "No_Activation_Acc = CASE WHEN (No_Activation + 1 > No_Max_Activation or (No_Activation_Acc + 1 > @no_acct_limit_total)) THEN No_Activation_Acc ELSE No_Activation_Acc + 1 END, " +
                                "No_Activation_Pending = CASE WHEN (No_Activation + 1 > No_Max_Activation or (No_Activation_Acc + 1 > @no_acct_limit_total)) THEN No_Activation_Pending + 1 ELSE No_Activation_Pending END, " +
                                "Updated_By = 'WEBSITE', " +
                                "Updated_Dttm = GETDATE() " +
                                "OUTPUT CASE WHEN (deleted.No_Activation + 1 > deleted.No_Max_Activation or deleted.No_Activation_Acc + 1 > @no_acct_limit_total) THEN 1 ELSE 0 END " +
                                " into @tbt " +
                                "WHERE [Date] = @today " +
                                "select @acstatus = acstatus from @tbt";

                            db_transaction.Database.ExecuteSqlCommand(sql_string, no_acct_total, date, output);

                            int sql_result = Convert.ToInt16(output.Value);

                            if (sql_result == 0)
                            {
                                account.Status_Cd       = FreebieStatus.AccountActivated();
                                account.Activation_Dttm = timestamp;
                                reply_str      = System.Configuration.ConfigurationManager.AppSettings["ACD"];
                                sms_log_result = "Register success";
                                string q_str = (Convert.ToByte(q.Quota_Freq_Val) * Convert.ToByte(q.Quota_Dur_Val) * 30).ToString();
                                reply_str = reply_str.Replace("{count}", q.Quota_Freq_Val.ToString());
                                reply_str = reply_str.Replace("{mins}", q.Quota_Dur_Val.ToString());
                                reply_str = reply_str.Replace("{num}", q_str);
                            }
                            else
                            {
                                account.Status_Cd = FreebieStatus.AccountPending();
                                reply_str         = System.Configuration.ConfigurationManager.AppSettings["AP"];
                                sms_log_result    = "Register Pending";
                            }

                            #endregion


                            account.First_Quota_Cd       = q.Quota_Cd;
                            account.First_Quota_Dur_Val  = q.Quota_Dur_Val;
                            account.First_Quota_Freq_Val = q.Quota_Freq_Val;
                            account.Dummy_Flag           = "0";

                            db_transaction.Accounts.Add(account);
                            db_transaction.SaveChanges();
                            scope.Complete();
                        }
                        #endregion
                        #region call_sp
                        result_sp = CallSP.SP_Insert_Interact_Profile(account.Account_Id);
                        if (!result_sp[0].Equals("0"))
                        {
                            using (var new_db = new EchoContext())
                            {
                                SqlParameter date = new SqlParameter("today", SqlDbType.Date);
                                date.Value = DateTime.Now;
                                Account remove_ac = new_db.Accounts.SingleOrDefault(x => x.Account_Id == account.Account_Id);
                                if (remove_ac != null)
                                {
                                    if (remove_ac.Status_Cd.Equals(FreebieStatus.AccountActivated()))
                                    {
                                        string sql_string =
                                            "UPDATE Account_Activation " +
                                            "SET No_Activation = CASE WHEN (No_Activation - 1 < 0 ) THEN 0 ELSE No_Activation - 1 END, " +
                                            "No_Activation_Acc = CASE WHEN (No_Activation_Acc - 1 < 0 ) THEN 0 ELSE No_Activation_Acc - 1 END, " +
                                            "Updated_By = 'WEBSITE', " +
                                            "Updated_Dttm = GETDATE() " +
                                            "WHERE [Date] = @today ";

                                        new_db.Database.ExecuteSqlCommand(sql_string, date);
                                    }
                                    else
                                    {
                                        if (remove_ac.Status_Cd.Equals(FreebieStatus.AccountPending()))
                                        {
                                            string sql_string =
                                                "UPDATE Account_Activation " +
                                                "SET No_Activation_Pending = CASE WHEN (No_Activation_Pending - 1 < 0 ) THEN 0 ELSE No_Activation_Pending - 1 END, " +
                                                "Updated_By = 'WEBSITE', " +
                                                "Updated_Dttm = GETDATE() " +
                                                "WHERE [Date] = @today ";

                                            new_db.Database.ExecuteSqlCommand(sql_string, date);
                                        }
                                    }
                                    AccountQuotaUsedCur remove_aquc = new_db.AccountQuotaUsedCurs.SingleOrDefault(x => x.Account_Id == account.Account_Id);
                                    if (remove_aquc != null)
                                    {
                                        new_db.AccountQuotaUsedCurs.Remove(remove_aquc);
                                    }
                                    new_db.Accounts.Remove(remove_ac);
                                    new_db.SaveChanges();
                                }
                            }
                            reply_str = System.Configuration.ConfigurationManager.AppSettings["NO_ACCTACTIVATION"];
                        }
                        else
                        {
                            FreebieEvent.AccountCreateEvent(account, account.First_Mobile_Number, Permission.f_cust_regis_page_id);
                        }
                        #endregion
                    }
                    else
                    {
                        reply_str      = System.Configuration.ConfigurationManager.AppSettings["WRONG_FORMAT"];
                        sms_log_result = "Wrong input Format";
                    }
                }
            }
            catch (Exception err)
            {
                reply_str      = System.Configuration.ConfigurationManager.AppSettings["NO_ACCTACTIVATION"];
                sms_log_result = "System Error";
                FreebieEvent.AddCustomError(err.Message, Permission.f_cust_regis_page_id);
            }

            Encoding encoding = Encoding.GetEncoding("tis-620");
            string   xml_str  = GetReplyXML(reply_str, encoding);

            sms_log.Result = sms_log_result;
            db.SmsRegistrationLogs.Add(sms_log);
            db.SaveChanges();

            context.Response.ContentType     = "text/xml";
            context.Response.ContentEncoding = encoding;
            context.Response.Write(xml_str);
        }
コード例 #3
0
        public ActionResult UpdateAccProfile()
        {
            int account_id = Convert.ToInt32(Session["Account_Id"].ToString());
            var account    = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id);

            if (account == null)
            {
                return(HttpNotFound());
            }

            var account_interest = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault();

            if (account_interest == null)
            {
                account_interest = new AccountInterest();
            }
            AccountQuota account_quota = db.AccountQuotas.SingleOrDefault(x => x.Account_Id == account_id);
            Quota        quota         = new Quota();

            if (account_quota == null)
            {
                account_quota = new AccountQuota();
            }
            else
            {
                quota = account_quota.Quota;
            }

            ViewBag.Quota_Freq_Val = Convert.ToInt16(quota.Quota_Freq_Val);
            ViewBag.Quota_Dur_Val  = Convert.ToInt16(quota.Quota_Dur_Val);

            Hashtable quotas = new Hashtable();

            quotas["low"]    = new Hashtable();
            quotas["medium"] = new Hashtable();
            quotas["high"]   = new Hashtable();
            IEnumerable <Quota> base_quotas = db.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).OrderBy(x => x.Quota_Cd);
            int q_count = 1;

            foreach (var q in base_quotas)
            {
                switch (q_count)
                {
                case 1:
                    quotas["low"] = q;
                    break;

                case 2:
                    quotas["medium"] = q;
                    break;

                case 3:
                    quotas["high"] = q;
                    break;

                default:
                    break;
                }

                q_count += 1;
            }
            ViewBag.Quotas = quotas;

            List <string> interest_arrs = load_interest(account_interest);

            ViewBag.InterestSelected = interest_arrs;

            init_dropdown(account);
            ViewBag.ViewProfile = "true";
            return(View(account));
        }
コード例 #4
0
        public ActionResult UpdateAccProfile(Account account)
        {
            var selected_interests = Request.Form["selectedInterests"];
            var agree_flag         = Request.Form["Agree"];

            ViewBag.NotAgree    = "";
            ViewBag.ViewProfile = "true";
            int account_id = Convert.ToInt32(Session["Account_Id"].ToString());

            account = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id);
            AccountQuota account_quota = db.AccountQuotas.SingleOrDefault(x => x.Account_Id == account_id);
            Quota        quota         = new Quota();

            if (account_quota == null)
            {
                account_quota = new AccountQuota();
            }
            else
            {
                quota = account_quota.Quota;
            }

            ViewBag.Quota_Freq_Val = Convert.ToInt16(quota.Quota_Freq_Val);
            ViewBag.Quota_Dur_Val  = Convert.ToInt16(quota.Quota_Dur_Val);

            Hashtable quotas = new Hashtable();

            quotas["low"]    = new Hashtable();
            quotas["medium"] = new Hashtable();
            quotas["high"]   = new Hashtable();
            IEnumerable <Quota> base_quotas = db.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).OrderBy(x => x.Quota_Cd);
            int q_count = 1;

            foreach (var q in base_quotas)
            {
                switch (q_count)
                {
                case 1:
                    quotas["low"] = q;
                    break;

                case 2:
                    quotas["medium"] = q;
                    break;

                case 3:
                    quotas["high"] = q;
                    break;

                default:
                    break;
                }

                q_count += 1;
            }
            ViewBag.Quotas = quotas;
            string old_idcard = account.Identification_Number == null ? string.Empty : account.Identification_Number.Trim();

            //Account old_account = account;

            if (account == null)
            {
                return(HttpNotFound());
            }
            if (ModelState.ContainsKey("User_Name"))
            {
                ModelState["User_Name"].Errors.Clear();
            }
            if (ModelState.ContainsKey("User_Name"))
            {
                ModelState["Password"].Errors.Clear();
            }
            var form_vals = Request.Form;

            if (string.IsNullOrWhiteSpace(form_vals["First_Name"]))
            {
                ModelState.AddModelError("First_Name", System.Configuration.ConfigurationManager.AppSettings["Account003"]);
            }

            if (string.IsNullOrWhiteSpace(form_vals["Last_Name"]))
            {
                ModelState.AddModelError("Last_Name", System.Configuration.ConfigurationManager.AppSettings["Account004"]);
            }

            if (string.IsNullOrWhiteSpace(form_vals["Income_Range_Cd"]))
            {
                ModelState.AddModelError("Income_Range_Cd", System.Configuration.ConfigurationManager.AppSettings["Account025"]);
            }
            if (CustomValidate.ValidateZipcode(form_vals["ZipCode"]) != 1)
            {
                ModelState.AddModelError("ZipCode", System.Configuration.ConfigurationManager.AppSettings["Account023"]);
            }

            account.First_Name = form_vals["First_Name"];
            account.Last_Name  = form_vals["Last_Name"];
            if (string.IsNullOrEmpty(form_vals["Day_Of_Birth"]))
            {
                account.Day_Of_Birth = null;
            }
            else
            {
                account.Day_Of_Birth = Convert.ToByte(form_vals["Day_Of_Birth"]);
            }
            if (string.IsNullOrEmpty(form_vals["Month_Of_Birth"]))
            {
                account.Month_Of_Birth = null;
            }
            else
            {
                account.Month_Of_Birth = Convert.ToByte(form_vals["Month_Of_Birth"]);
            }
            if (string.IsNullOrEmpty(form_vals["Year_Of_Birth"]))
            {
                account.Year_Of_Birth = null;
            }
            else
            {
                account.Year_Of_Birth = Convert.ToInt16(form_vals["Year_Of_Birth"]);
            }
            account.Gender_Cd         = form_vals["Gender_Cd"];
            account.Marital_Status_Cd = form_vals["Marital_Status_Cd"];

            bool no_child = true;

            if (!string.IsNullOrEmpty(form_vals["Children_Flag"]))
            {
                if (form_vals["Children_Flag"].Equals("Y"))
                {
                    account.Children_Flag = "Y";
                    no_child = false;
                }
                else
                {
                    account.Children_Flag = "N";
                }
            }

            if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child1"]))
            {
                account.Year_Of_Birth_Child1 = null;
            }
            else
            {
                account.Year_Of_Birth_Child1 = Convert.ToInt16(form_vals["Year_Of_Birth_Child1"]);
            }
            if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child2"]))
            {
                account.Year_Of_Birth_Child2 = null;
            }
            else
            {
                account.Year_Of_Birth_Child2 = Convert.ToInt16(form_vals["Year_Of_Birth_Child2"]);
            }
            if (no_child || string.IsNullOrEmpty(form_vals["Year_Of_Birth_Child3"]))
            {
                account.Year_Of_Birth_Child3 = null;
            }
            else
            {
                account.Year_Of_Birth_Child3 = Convert.ToInt16(form_vals["Year_Of_Birth_Child3"]);
            }



            account.Income_Range_Cd       = form_vals["Income_Range_Cd"];
            account.Occupation_Cd         = form_vals["Occupation_Cd"];
            account.Education_Cd          = form_vals["Education_Cd"];
            account.Identification_Number = form_vals["Identification_Number"];

            string idcard = form_vals["Identification_Number"] == null ? string.Empty : form_vals["Identification_Number"].Trim();

            if (!string.IsNullOrEmpty(idcard))
            {
                switch (CustomValidate.ValidateIndentification(idcard))
                {
                case 0:
                    ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account007"]);
                    break;

                case 2:
                    ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account007"]);
                    break;

                case 3:
                    ModelState.AddModelError("Identification_Number", System.Configuration.ConfigurationManager.AppSettings["Account008"]);
                    break;

                default:
                    break;
                }
            }
            if (!string.IsNullOrEmpty(account.Children_Flag))
            {
                if (account.Children_Flag.Equals("Y"))
                {
                    if (account.Year_Of_Birth_Child1 == null)
                    {
                        ModelState.AddModelError("Year_Of_Birth_Child1", System.Configuration.ConfigurationManager.AppSettings["Account021"]);
                    }
                }
            }
            if (account.Day_Of_Birth == null || account.Month_Of_Birth == null || account.Year_Of_Birth == null)
            {
                ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account020"]);
            }
            if (account.Month_Of_Birth == 2)
            {
                if (account.Day_Of_Birth > 29)
                {
                    ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account019"]);
                }
                else
                {
                    if (!(account.Year_Of_Birth % 400 == 0 || (account.Year_Of_Birth % 100 != 0 && account.Year_Of_Birth % 4 == 0)))
                    {
                        if (account.Day_Of_Birth == 29)
                        {
                            ModelState.AddModelError("Day_Of_Birth", System.Configuration.ConfigurationManager.AppSettings["Account019"]);
                        }
                    }
                }
            }
            if (agree_flag == "true")
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        account.Updated_Dttm = DateTime.Now;
                        UpdateModel(account);

                        string[] interests = new string[] { };

                        var  aci  = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault();
                        bool flag = false;
                        if (aci == null)
                        {
                            aci            = new AccountInterest();
                            aci.Account_Id = account.Account_Id;
                            flag           = true;
                        }

                        if (selected_interests != null)
                        {
                            interests = selected_interests.Split(',');
                        }
                        aci.I01_Food_Dining        = interests.Contains("I01");
                        aci.I02_Night_Life         = interests.Contains("I02");
                        aci.I03_Entertainment      = interests.Contains("I03");
                        aci.I04_Music_Movie        = interests.Contains("I04");
                        aci.I05_Sports_Fitness     = interests.Contains("I05");
                        aci.I06_Shopping_Fashion   = interests.Contains("I06");
                        aci.I07_Health_Beauty      = interests.Contains("I07");
                        aci.I08_Travel             = interests.Contains("I08");
                        aci.I09_Pets               = interests.Contains("I09");
                        aci.I10_Kids_Children      = interests.Contains("I10");
                        aci.I11_Home_Living        = interests.Contains("I11");
                        aci.I12_Finance_Investment = interests.Contains("I12");
                        aci.I13_Technology_Gadget  = interests.Contains("I13");
                        aci.I14_Auto               = interests.Contains("I14");

                        if (flag)
                        {
                            db.AccountInterests.Add(aci);
                        }
                        else
                        {
                            db.Entry(aci).State = EntityState.Modified;
                        }

                        Quota        select_quota = QuotaCalculation.Calculate(account, selected_interests);
                        AccountQuota aq           = db.AccountQuotas.SingleOrDefault(x => x.Account_Id.Equals(account_id));
                        if (aq != null)
                        {
                            db.AccountQuotas.Remove(aq);
                            db.SaveChanges();
                        }
                        AccountQuota new_aq = new AccountQuota();

                        new_aq.Account_Id = account_id;
                        new_aq.Quota_Cd   = select_quota.Quota_Cd;
                        db.AccountQuotas.Add(new_aq);

                        db.SaveChanges();
                        if (!old_idcard.Equals(idcard))
                        {
                            FreebieEvent.AccountUpdateEvent(account, idcard, "Idcard", Permission.f_update_profile_page_id);
                        }
                        else
                        {
                            FreebieEvent.AccountUpdateEvent(account, null, null, Permission.f_update_profile_page_id);
                        }
                        return(RedirectToAction("ViewAccProfile"));
                    }
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
            }
            else
            {
                ViewBag.NotAgree = System.Configuration.ConfigurationManager.AppSettings["Account006"];
            }

            var account_interest = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault();

            if (account_interest == null)
            {
                account_interest = new AccountInterest();
            }

            List <string> interest_arrs = load_interest(account_interest);

            ViewBag.InterestSelected = interest_arrs;
            init_dropdown(account);
            ViewBag.Step = 3;

            return(View(account));
        }
コード例 #5
0
        public ActionResult ViewAccProfile()
        {
            int account_id = Convert.ToInt32(Session["Account_Id"].ToString());
            var account    = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id);

            if (account == null)
            {
                return(HttpNotFound());
            }

            var account_interest = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault();

            if (account_interest == null)
            {
                account_interest = new AccountInterest();
            }

            List <string> interest_arrs = load_interest(account_interest);

            ViewBag.InterestSelected = interest_arrs;
            AccountQuota account_quota = db.AccountQuotas.SingleOrDefault(x => x.Account_Id == account_id);
            Quota        quota         = new Quota();

            if (account_quota == null)
            {
                account_quota = new AccountQuota();
            }
            else
            {
                quota = account_quota.Quota;
            }

            string district = "";

            if (!string.IsNullOrWhiteSpace(account.AreaCode))
            {
                Zipcode zipcode = db.Zipcodes.SingleOrDefault(x => x.AreaCode.Equals(account.AreaCode));
                if (zipcode != null)
                {
                    district = zipcode.District;
                }
            }

            ViewBag.Quota_Freq_Val = Convert.ToInt16(quota.Quota_Freq_Val);
            ViewBag.Quota_Dur_Val  = Convert.ToInt16(quota.Quota_Dur_Val);

            if (quota.Quota_Cd != null)
            {
                if (quota.Quota_Cd.Equals("Q0001"))
                {
                    ViewBag.Score = 3;
                }
                else
                {
                    if (quota.Quota_Cd.Equals("Q0002"))
                    {
                        ViewBag.Score = 6;
                    }
                    else
                    {
                        if (quota.Quota_Cd.Equals("Q0003"))
                        {
                            ViewBag.Score = 8;
                        }
                        else
                        {
                            ViewBag.Score = 0;
                        }
                    }
                }
            }



            ViewBag.District = district;

            Hashtable quotas = new Hashtable();

            quotas["low"]    = new Hashtable();
            quotas["medium"] = new Hashtable();
            quotas["high"]   = new Hashtable();
            IEnumerable <Quota> base_quotas = db.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).OrderBy(x => x.Quota_Cd);
            int q_count = 1;

            foreach (var q in base_quotas)
            {
                switch (q_count)
                {
                case 1:
                    quotas["low"] = q;
                    break;

                case 2:
                    quotas["medium"] = q;
                    break;

                case 3:
                    quotas["high"] = q;
                    break;

                default:
                    break;
                }

                q_count += 1;
            }
            ViewBag.Quotas = quotas;
            init_dropdown(account);
            ViewBag.ViewProfile = "true";
            return(View(account));
        }