Example #1
0
        private void DownloadSort(TransferObjectModel transferObject)
        {
            if (Downloads.Contains(transferObject))
            {
                if (!Downloads.Remove(transferObject))
                {
                    return;
                }
            }

            var inserted = false;

            for (var i = 0; i <= Downloads.Count - 1; i++)
            {
                if ((int)transferObject.Status <= (int)Downloads[i].Status)
                {
                    Downloads.Insert(i, transferObject);
                    inserted = true;
                    break;
                }
            }

            if (!inserted)
            {
                Downloads.Add(transferObject);
            }
        }
Example #2
0
        private void AddDownload(DownloadViewModel download)
        {
            // Find an existing download for this file path
            var existingDownload = Downloads.FirstOrDefault(d => d.FilePath == download.FilePath);

            // If it exists - cancel and remove it
            if (existingDownload != null)
            {
                if (existingDownload.CanCancel)
                {
                    existingDownload.Cancel();
                }

                Downloads.Remove(existingDownload);
            }

            // Add to the beginning
            Downloads.Insert(0, download);
        }
    private void Save()
    {
        try{
            string id;
            GetId();

            if (ddListOperation.SelectedValue == "-- Create New --")
            {
                id = AdminBaseUIPage.GetID("downloadable");
                if (id == "")
                {
                    id = "1";
                }
                if (Downloads.Insert(int.Parse(id), int.Parse(Id), txtTitle.Text, txtFileName.Text, FCKeditor1.Value, txtSize.Text, int.Parse(cmbDocType.SelectedValue), "D", DateTime.Now))
                {
                    lblMessage.Text = "The content was succesfully saved.";
                }
                else
                {
                    lblMessage.Text = "There was problem saving the content.";
                }
            }
            else
            {
                id = ddListOperation.SelectedValue;
                if (Downloads.Update(int.Parse(id), txtTitle.Text, txtFileName.Text, FCKeditor1.Value, txtSize.Text, int.Parse(cmbDocType.SelectedValue), DateTime.Now))
                {
                    lblMessage.Text = "The content was succesfully saved.";
                }
                else
                {
                    lblMessage.Text = "There was problem saving the content.";
                }
            }

            Populate();
        }
        catch { }
    }