public IActionResult UpdateProduct(MembershipProperty model)
        {
            model.Code = AppGlobal.Product;
            string note   = AppGlobal.InitString;
            int    result = 0;

            model.Initialization(InitType.Update, RequestUserID);
            result = _membershipPropertyRepository.Update(model.ID, model);
            if (result > 0)
            {
                note = AppGlobal.Success + " - " + AppGlobal.EditSuccess;
            }
            else
            {
                note = AppGlobal.Error + " - " + AppGlobal.EditFail;
            }
            return(Json(note));
        }
Exemplo n.º 2
0
        public ApiMembership(DataRow dataRow)
        {
            this.name       = dataRow["Name"].ToString();
            this.color      = dataRow["Color"].ToString();
            this.properties = new List <KeyValuePair <string, string> >();

            var hiddenProperties = MembershipProperty.GetPropsToHideForClient();
            var columnNames      = dataRow.Table.Columns.Cast <DataColumn>()
                                   .Select(x => new KeyValuePair <string, int>(x.ColumnName, x.Ordinal)).ToList();

            foreach (var columnName in columnNames)
            {
                if (columnName.Key != "Name" && columnName.Key != "Color" && !hiddenProperties.Contains(columnName.Key))
                {
                    properties.Add(
                        new KeyValuePair <string, string>(MembershipProperty.GetResourceLabel(columnName.Key),
                                                          MembershipProperty.Format(columnName.Value, dataRow[columnName.Key].ToString(), false))
                        );
                }
            }
        }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var targetFeature  = PurchaseOption.Features.Upgrade;
        var purchaseOption = PurchaseOption.Get(targetFeature);

        if (purchaseOption.PurchaseBalanceEnabled)
        {
            UpgradeFromAdBalance.Visible = true;
        }
        else
        {
            UpgradeFromAdBalance.Visible = false;
            adBalanceInfo.Visible        = false;
        }

        if (AppSettings.Payments.CashBalanceEnabled && purchaseOption.CashBalanceEnabled)
        {
            UpgradeFromCashBalance.Visible = true;
        }
        else
        {
            UpgradeFromCashBalance.Visible = false;
            cashBalanceInfo.Visible        = false;
        }

        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.UpgradeEnabled);

        User = Member.CurrentInCache;

        if (!Page.IsPostBack)
        {
            //Lang
            LangAdder.Add(UpgradeFromAdBalance, U6012.PAYVIAPURCHASEBALANCE);
            LangAdder.Add(UpgradeFromCashBalance, U6005.PAYVIACASHBALANCE);
            LangAdder.Add(UpgradeViaPaymentProcessor, U6005.PAYVIAPAYMENTPROCESSOR);

            //Bind the data dor DDL
            BindDataToDDL();

            //Visibility
            UpgradeViaPaymentProcessorPlaceHolder.Visible = PaymentAccountDetails.AreIncomingPaymentProcessorsAvailable();
        }

        if (TitanFeatures.IsRofriqueWorkMines)
        {
            UpgradeFromAdBalancePlaceHolder.Visible       = false;
            UpgradeViaPaymentProcessorPlaceHolder.Visible = false;
        }

        HideCashBalanceDepositCommissionColumn = AreAllCashBalanceDepositCommissionsZero();

        ddlOptions.Attributes.Add("onchange", "updatePrice();");
        autopayHelpArray = new Dictionary <string, bool>();

        Label10.Text  = AppSettings.Memberships.TenPointsValue.ToClearString();
        LabelIle.Text = AppSettings.Memberships.UpgradePointsDiscount.ToString();

        //Display warning
        string WarningMessage = UpgradePageHelper.GetWarningMessage(User);

        WarningPanel.Visible = !String.IsNullOrEmpty(WarningMessage);
        WarningLiteral.Text  = WarningMessage;

        AdBalanceLiteral.Text   = User.PurchaseBalance.ToString();
        CashBalanceLiteral.Text = User.CashBalance.ToString();

        if (AppSettings.Points.LevelMembershipPolicyEnabled)
        {
            BuyUpgradePlaceHolder.Visible = false;
        }

        hiddenProperties = MembershipProperty.GetPropsToHideForClient();
        TypesMembershipProperties.Text = AdPackTypeMembershipMapper.Mapper.GetHtmlFromCache();
        AdPackPropsPlaceHolder.Visible = AppSettings.TitanFeatures.AdvertAdPacksEnabled;

        PaymentProcessorsButtonPlaceholder.Visible = false;
    }
Exemplo n.º 4
0
    protected void UpgradeGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //Create an instance of the datarow
            var rowData = e.Row.Cells[1].Text;

            //Set proper width
            //e.Row.Cells[0].ControlStyle.Width = Unit.Pixel(230);
            foreach (TableCell tc in e.Row.Cells)
            {
                if (tc != e.Row.Cells[0])
                {
                    //tc.ControlStyle.Width = Unit.Pixel(50);
                    tc.ControlStyle.CssClass = "text-center";
                }
            }


            if (hiddenProperties.Any(p => p == e.Row.Cells[0].Text))
            {
                e.Row.CssClass = "displaynone";
            }

            //Add image to index 1 (name)
            if (e.Row.RowIndex == 1)
            {
                int indexOfUpgrade = 0;
                foreach (TableCell tc in e.Row.Cells)
                {
                    if (tc != e.Row.Cells[0])
                    {
                        string upgradeName = tc.Text;
                        string imageName   = "standardbox";
                        if (upgradeName != Membership.Standard.Name)
                        {
                            //Because max premiumimagename is 7
                            //I know it is shitty work
                            imageName = (indexOfUpgrade > 7) ? "premiumbox7" : "premiumbox" + indexOfUpgrade.ToString();
                        }
                        tc.Text = "<div class=\"text-center\"><p><strong>" + upgradeName + "</strong></p><img src=\"Images/OneSite/Upgrade/" + imageName + ".png\" /></div>";
                        indexOfUpgrade++;
                    }
                }
            }

            e.Row.Cells[0].Text = MembershipProperty.GetResourceLabel(e.Row.Cells[0].Text);


            foreach (TableCell tc in e.Row.Cells)
            {
                if (tc != e.Row.Cells[0])
                {
                    tc.Text = MembershipProperty.Format(e.Row.RowIndex, tc.Text);
                }
            }


            //Add color
            if (e.Row.RowIndex == 12)
            {
                foreach (TableCell tc in e.Row.Cells)
                {
                    if (tc != e.Row.Cells[0])
                    {
                        tc.Text = "<div class=\"upgrade-table-label\" style=\"background-color:" + tc.Text + ";\">&nbsp;</div>";
                    }
                }
            }


            //Hide AutoPay price if no autopay
            if (e.Row.RowIndex == 15)
            {
                foreach (TableCell tc in e.Row.Cells)
                {
                    if (tc != e.Row.Cells[0] && tc.Text.Contains("$0.000"))
                    {
                        tc.Text = "&nbsp;";
                    }
                }
            }
        }
        else if (e.Row.RowType == DataControlRowType.Header)
        {
            foreach (TableCell tc in e.Row.Cells)
            {
                tc.Text = "&nbsp;";
            }
        }
    }
Exemplo n.º 5
0
        public ActionResult UploadInvoice(BaseViewModel viewModel)
        {
            int    result     = 0;
            string action     = "Upload";
            string controller = "Membership";

            try
            {
                if (Request.Form.Files.Count > 0)
                {
                    var file = Request.Form.Files[0];
                    if (file == null || file.Length == 0)
                    {
                    }
                    if (file != null)
                    {
                        string fileExtension = Path.GetExtension(file.FileName);
                        string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                        fileName = "Invoice";
                        fileName = fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                        var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.FTPUploadExcel, fileName);
                        using (var stream = new FileStream(physicalPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                            FileInfo fileLocation = new FileInfo(physicalPath);
                            if (fileLocation.Length > 0)
                            {
                                if ((fileExtension == ".xlsx") || (fileExtension == ".xls"))
                                {
                                    using (ExcelPackage package = new ExcelPackage(stream))
                                    {
                                        if (package.Workbook.Worksheets.Count > 0)
                                        {
                                            ExcelWorksheet workSheet = package.Workbook.Worksheets[1];
                                            if (workSheet != null)
                                            {
                                                int totalRows = workSheet.Dimension.Rows;
                                                for (int i = 2; i <= totalRows; i++)
                                                {
                                                    Membership model = new Membership();
                                                    if (workSheet.Cells[i, 7].Value != null)
                                                    {
                                                        model.TaxCode = workSheet.Cells[i, 7].Value.ToString().Trim();
                                                        model.TaxCode = model.TaxCode.Replace(@" ", @"");
                                                        model         = _membershipRepository.GetByTaxCode(model.TaxCode);
                                                        if (model != null)
                                                        {
                                                            MembershipProperty membershipProperty = new MembershipProperty();
                                                            membershipProperty.MembershipID = model.ID;
                                                            if (workSheet.Cells[i, 1].Value != null)
                                                            {
                                                                membershipProperty.PaymentCode = workSheet.Cells[i, 1].Value.ToString().Trim();
                                                            }
                                                            if (workSheet.Cells[i, 2].Value != null)
                                                            {
                                                                membershipProperty.ProductCode = workSheet.Cells[i, 2].Value.ToString().Trim();
                                                            }
                                                            decimal valueContract = 0;
                                                            if (workSheet.Cells[i, 3].Value != null)
                                                            {
                                                                try
                                                                {
                                                                    valueContract = decimal.Parse(workSheet.Cells[i, 3].Value.ToString().Trim());
                                                                }
                                                                catch
                                                                {
                                                                }
                                                            }
                                                            membershipProperty = _membershipPropertyRepository.GetByMembershipIDAndPaymentCodeAndProductCode(membershipProperty.MembershipID.Value, membershipProperty.PaymentCode, membershipProperty.ProductCode);
                                                            if (membershipProperty == null)
                                                            {
                                                                membershipProperty = new MembershipProperty();
                                                                membershipProperty.MembershipID = model.ID;
                                                                if (workSheet.Cells[i, 1].Value != null)
                                                                {
                                                                    membershipProperty.PaymentCode = workSheet.Cells[i, 1].Value.ToString().Trim();
                                                                }
                                                                if (workSheet.Cells[i, 2].Value != null)
                                                                {
                                                                    membershipProperty.ProductCode = workSheet.Cells[i, 2].Value.ToString().Trim();
                                                                }
                                                                Config product = new Config();
                                                                if (workSheet.Cells[i, 4].Value != null)
                                                                {
                                                                    product.Title = workSheet.Cells[i, 4].Value.ToString().Trim();
                                                                    product       = _configResposistory.GetByGroupNameAndCodeAndTitle(AppGlobal.CRM, AppGlobal.Product, product.Title);
                                                                    if (product == null)
                                                                    {
                                                                        product = new Config();
                                                                        product.Initialization(InitType.Insert, RequestUserID);
                                                                        product.GroupName = AppGlobal.CRM;
                                                                        product.Code      = AppGlobal.Product;
                                                                        product.Title     = workSheet.Cells[i, 4].Value.ToString().Trim();
                                                                        _configResposistory.Create(product);
                                                                    }
                                                                    membershipProperty.ProductID = product.ID;
                                                                }

                                                                if (membershipProperty.MembershipID > 0)
                                                                {
                                                                    membershipProperty.Code          = AppGlobal.Product;
                                                                    membershipProperty.ValueContract = valueContract;
                                                                    membershipProperty.DateBegin     = DateTime.Now;
                                                                    membershipProperty.DateEnd       = DateTime.Now;
                                                                    membershipProperty.DateContract  = DateTime.Now;
                                                                    membershipProperty.Address       = model.Address;
                                                                    membershipProperty.Initialization(InitType.Insert, RequestUserID);
                                                                    _membershipPropertyRepository.Create(membershipProperty);
                                                                }
                                                            }
                                                            if (membershipProperty != null)
                                                            {
                                                                Invoice invoice = new Invoice();
                                                                invoice.ContractID = membershipProperty.ID;
                                                                invoice.Year       = viewModel.YearFinance;
                                                                invoice.Month      = viewModel.MonthFinance;
                                                                invoice            = _invoiceRepository.GetByContractIDAndYearAndMonth(invoice.ContractID.Value, invoice.Year.Value, invoice.Month.Value);
                                                                if (invoice == null)
                                                                {
                                                                    invoice            = new Invoice();
                                                                    invoice.ContractID = membershipProperty.ID;
                                                                    invoice.Year       = viewModel.YearFinance;
                                                                    invoice.Month      = viewModel.MonthFinance;
                                                                    invoice.Initialization(InitType.Insert, RequestUserID);
                                                                    invoice.ContractID  = membershipProperty.ID;
                                                                    invoice.Year        = viewModel.YearFinance;
                                                                    invoice.Month       = viewModel.MonthFinance;
                                                                    invoice.DateInvoice = new DateTime(invoice.Year.Value, invoice.Month.Value, 28);
                                                                    invoice.Total       = valueContract;
                                                                    _invoiceRepository.Create(invoice);
                                                                }
                                                                if (invoice != null)
                                                                {
                                                                    InvoiceProperty invoiceProperty = _invoicePropertyRepository.GetByInvoiceIDAndProductID(invoice.ID, membershipProperty.ProductID.Value);
                                                                    if (invoiceProperty == null)
                                                                    {
                                                                        invoiceProperty = new InvoiceProperty();
                                                                        invoiceProperty.Initialization(InitType.Insert, RequestUserID);
                                                                        invoiceProperty.InvoiceID = invoice.ID;
                                                                        invoiceProperty.ProductID = membershipProperty.ProductID;
                                                                        invoiceProperty.UnitID    = AppGlobal.UnitID;
                                                                        invoiceProperty.Quantity  = 1;
                                                                        invoiceProperty.UnitPrice = valueContract;
                                                                        invoiceProperty.Total     = invoiceProperty.Quantity * invoiceProperty.UnitPrice;
                                                                        _invoicePropertyRepository.Create(invoiceProperty);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                result = 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            if (result > 0)
            {
                action     = "Customer";
                controller = "Membership";
            }
            return(RedirectToAction(action, controller, new { ID = result }));
        }