Ejemplo n.º 1
0
 protected void btnDelAttachment_Command(Object sender, CommandEventArgs e)
 {
     if (null != e.CommandArgument)
     {
         int        id         = Convert.ToInt32(e.CommandArgument);
         Attachment attachment = PortfolioService.GetAttachment(id);
         PortfolioService.DeleteAttachment(attachment);
         LoadPortfolio();
     }
 }
Ejemplo n.º 2
0
    private void SavePortfolio(int index)
    {
        Portfolio portfolio = GetPortfolio();

        switch (index)
        {
        case 0:
            CurrentUser.FullName    = txtName.Text;
            portfolio.Parents       = txtParents.Text;
            portfolio.Address       = txtAddress.Text;
            portfolio.City          = txtCity.Text;
            portfolio.State         = ddlState.SelectedValue;
            portfolio.Zip           = txtZip.Text;
            CurrentUser.PhoneNumber = txtPhone.Text;
            portfolio.Sex           = (Sexes)Enum.Parse(typeof(Sexes), ddlGender.SelectedValue.ToString());
            UserService.SaveUser(CurrentUser);
            break;

        case 1:
            SavePortfolio(portfolio);
            break;

        case 2:
            break;

        case 3:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtCategory" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Category, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Category, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Category, i);
                    }
                }
            }
            break;

        case 4:
        {
            if (!String.IsNullOrEmpty(txtCategoryDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                item.Text = txtCategoryDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.CategoryDescription, 0);
                }
            }
        }
        break;

        case 5:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtLeadership" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Leadership, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Leadership, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Leadership, i);
                    }
                }
            }
            break;

        case 6:
            if (!String.IsNullOrEmpty(txtLeadershipDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                item.Text = txtLeadershipDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.LeadershipDescription, 0);
                }
            }
            break;

        case 7:
            for (int i = 0; i < 6; i++)
            {
                TextBox tb = AccordianControl.FindControl("txtCitizenship" + i.ToString()) as TextBox;
                if (tb != null && !string.IsNullOrEmpty(tb.Text))
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Citizenship, i);
                    item.Text = tb.Text;
                }
                else
                {
                    PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.Citizenship, i);
                    if (null != item)
                    {
                        PortfolioService.RemovePortfolioItem(portfolio, ItemType.Citizenship, i);
                    }
                }
            }
            break;

        case 8:
            if (!String.IsNullOrEmpty(txtCitizenshipDescription.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                item.Text = txtCitizenshipDescription.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.CitizenshipDescription, 0);
                }
            }
            break;

        case 9:
            if (!String.IsNullOrEmpty(txtUniqueQualities.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                item.Text = txtUniqueQualities.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.UniqueQualities, 0);
                }
            }
            break;

        case 10:

            if (!String.IsNullOrEmpty(txtLifeEnrichment.Text))
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                item.Text = txtLifeEnrichment.Text;
            }
            else
            {
                PortfolioItem item = PortfolioService.GetPortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                if (null != item)
                {
                    PortfolioService.RemovePortfolioItem(portfolio, ItemType.LifeEnrichment, 0);
                }
            }
            break;

        case 11:
        {
            IList <Attachment> list = PortfolioService.GetAttachments(AttachmentCategory.Url, AttachmentType.Portfolio, portfolio.Id);
            var attachment          = list.FirstOrDefault(x => "Document".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtDocLink.Text))
            {
                SaveUrl(attachment, "Document", txtDocDescription.Text, txtDocLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            attachment = list.FirstOrDefault(x => "Image".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtImageLink.Text))
            {
                SaveUrl(attachment, "Image", txtImageDescription.Text, txtImageLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            attachment = list.FirstOrDefault(x => "Media".Equals(x.Name));
            if (!string.IsNullOrEmpty(txtMediaLink.Text))
            {
                SaveUrl(attachment, "Media", txtMediaDescription.Text, txtMediaLink.Text, portfolio);
            }
            else if (null != attachment)
            {
                PortfolioService.DeleteAttachment(attachment);
            }
            break;
        }

        default:
            break;
        }
        PortfolioService.Save(portfolio);
    }