protected void lnkSaveFileInfo_Click(object sender, EventArgs e)
        {
            int ResourceId = 0;
            try
            {
                //ok, now we need to get all the information for the save
                //reource basic infortmation
                UploadData resourceData = new UploadData();
                resourceData.PortalId = ModuleContext.PortalId;
                resourceData.ResourceDescription = txtResourceDescription.Text;
                resourceData.ResourceLanguageId = int.Parse(ddlResourceLanguage.SelectedValue);
                resourceData.ResourceName = txtResourceName.Text;
                resourceData.ResourceTopicId = int.Parse(hidTopicId.Value);
                resourceData.ResourceTypeId = 1;
                resourceData.ResourceFormatId = int.Parse(ddlResourceFormat.SelectedValue);

                HttpWebRequest request = WebRequest.Create(dashboardUrlBase + "resourceupload/") as HttpWebRequest;
                request.Method = "POST";
                request.ContentType = "text/json";
                try
                {
                    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                    {
                        string json = JsonConvert.SerializeObject(resourceData);

                        streamWriter.Write(json);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                    var httpResponse = (HttpWebResponse)request.GetResponse();

                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.ToString());
                }

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                        throw new Exception(String.Format("Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
                    Stream resp = response.GetResponseStream();
                    StreamReader reader = new StreamReader(resp);
                    string text = reader.ReadToEnd();
                    ResourceId = int.Parse(text);
                }
                //end of basic information

                //now it is tags
                List<string> tagsSend = new List<string>();
                string tags = txtResourceTags.Text;
                if (tags.Contains(","))
                {
                    //these tags must be split
                    string[] tagsList = tags.Split(",");
                    foreach (var item in tagsList)
                    {
                        string tmp = item;
                        if (tmp.StartsWith(" "))
                        {
                            tmp = tmp.Remove(0, 1);
                        }
                        if (item.EndsWith(" "))
                        {
                            tmp = tmp.Remove(tmp.Length - 2, 1);
                        }
                        tagsSend.Add(tmp);
                    }
                }
                else
                {
                    if (tags.StartsWith(" "))
                    {
                        tags = tags.Remove(0, 1);
                    }
                    if (tags.EndsWith(" "))
                    {
                        tags = tags.Remove(tags.Length - 2, 1);
                    }
                    tagsSend.Add(tags);
                }
                TagsInfo tmpTags = new TagsInfo();
                tmpTags.ResourceId = ResourceId;
                tmpTags.tags = new List<string>();
                tmpTags.tags = tagsSend;

                HttpWebRequest tagrequest = WebRequest.Create(dashboardUrlBase + "resourcelist/" + ResourceId) as HttpWebRequest;
                tagrequest.Method = "POST";
                tagrequest.ContentType = "text/json";
                try
                {
                    using (var streamWriter = new StreamWriter(tagrequest.GetRequestStream()))
                    {
                        string json = JsonConvert.SerializeObject(tmpTags);

                        streamWriter.Write(json);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                    var httpResponse = (HttpWebResponse)tagrequest.GetResponse();
                }
                catch (Exception ex)
                {
                    lnkSaveFileInfo.Text = ex.ToString();
                }
                //end of tags

                //now its the files
                List<FileInfoData> tmpFileData = new List<FileInfoData>();
                List<FileData> newFileData = new List<FileData>();
                int filecounter = 0;
                try
                {
                    newFileData = JsonConvert.DeserializeObject<List<FileData>>(hidFileData.Value);
                }
                catch (Exception ex)
                {
                    lnkSaveFileInfo.Text = ex.Message;
                }

                foreach (RepeaterItem item in rptFileInfo.Items)
                {
                    int fileid = 0;
                    FileData tmpFile = newFileData[filecounter];
                    HttpWebRequest filerequest = WebRequest.Create(dashboardUrlBase + "resourceupload/" + ResourceId) as HttpWebRequest;
                    filerequest.ContentType = "text/json";
                    filerequest.Method = "POST";
                    try
                    {
                        using (var streamWriter = new StreamWriter(filerequest.GetRequestStream()))
                        {
                            string json = JsonConvert.SerializeObject(tmpFile);

                            streamWriter.Write(json);
                            streamWriter.Flush();
                            streamWriter.Close();
                        }
                        var httpFileResponse = (HttpWebResponse)filerequest.GetResponse();
                        //when we get the response we need to get the object returned.
                        //then show the author and publisher information upload.
                        Stream resp = httpFileResponse.GetResponseStream();
                        StreamReader reader = new StreamReader(resp);
                        string text = reader.ReadToEnd();
                        ResourceFile resourcefileReturn = JsonConvert.DeserializeObject<ResourceFile>(text);
                        fileid = resourcefileReturn.fileid;
                        filecounter++;
                    }
                    catch (Exception ex)
                    {
                        lnkSaveFileInfo.Text = ex.ToString();
                        return;
                    }

                    DropDownList author = (DropDownList)item.FindControl("ddlAuthor");
                    DropDownList publisher = (DropDownList)item.FindControl("ddlPublisher");
                    DropDownList year = (DropDownList)item.FindControl("ddlYear");

                    FileInfoData tmpFData = new FileInfoData();
                    tmpFData.resourceid = ResourceId;
                    tmpFData.authorid = int.Parse(author.SelectedValue);
                    tmpFData.publisherid = int.Parse(publisher.SelectedValue);
                    tmpFData.publishYear = int.Parse(year.SelectedValue);
                    tmpFData.fileid = fileid;
                    tmpFileData.Add(tmpFData);

                    HttpWebRequest fileInfoRequest = WebRequest.Create(dashboardUrlBase + "resourcefile") as HttpWebRequest;
                    fileInfoRequest.ContentType = "text/json";
                    fileInfoRequest.Method = "POST";
                    try
                    {
                        using (var streamWriter = new StreamWriter(fileInfoRequest.GetRequestStream()))
                        {
                            string json = JsonConvert.SerializeObject(tmpFData);

                            streamWriter.Write(json);
                            streamWriter.Flush();
                            streamWriter.Close();
                        }
                        var httpResponse = (HttpWebResponse)fileInfoRequest.GetResponse();

                    }
                    catch (Exception ex)
                    {
                        lnkSaveFileInfo.Text = ex.ToString();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.InnerException.ToString());
            }
            hidResourceId.Value = ResourceId.ToString();
            divFileinfo.Visible = false;
            divUploadPreviewImage.Visible = true;
        }
        protected void UploadWebsite_Click(object sender, EventArgs e)
        {
            int ResourceId = 0;
            //ok, now we need to get all the information for the save
            //reource basic infortmation
            UploadData resourceData = new UploadData();
            resourceData.PortalId = ModuleContext.PortalId;
            resourceData.ResourceDescription = txtResourceDescription.Text;
            resourceData.ResourceLanguageId = int.Parse(ddlResourceLanguage.SelectedValue);
            resourceData.ResourceName = txtResourceName.Text;
            resourceData.ResourceTopicId = int.Parse(hidTopicId.Value);
            resourceData.ResourceTypeId = 2;
            resourceData.ResourceFormatId = int.Parse(ddlResourceFormat.SelectedValue);

            HttpWebRequest request = WebRequest.Create(dashboardUrlBase + "resourceupload/") as HttpWebRequest;
            request.Method = "POST";
            request.ContentType = "text/json";
            try
            {
                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(resourceData);

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var httpResponse = (HttpWebResponse)request.GetResponse();

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                    throw new Exception(String.Format("Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription));
                Stream resp = response.GetResponseStream();
                StreamReader reader = new StreamReader(resp);
                string text = reader.ReadToEnd();
                ResourceId = int.Parse(text);
            }
            //end of basic information

            //now it is tags
            List<string> tagsSend = new List<string>();
            string tags = txtResourceTags.Text;
            if (tags.Contains(","))
            {
                //these tags must be split
                string[] tagsList = tags.Split(",");
                foreach (var item in tagsList)
                {
                    string tmp = item;
                    if (tmp.StartsWith(" "))
                    {
                        tmp = tmp.Remove(0, 1);
                    }
                    if (item.EndsWith(" "))
                    {
                        tmp = tmp.Remove(tmp.Length - 1, 1);
                    }
                    tagsSend.Add(tmp);
                }
            }
            else
            {
                if (tags.StartsWith(" "))
                {
                    tags = tags.Remove(0, 1);
                }
                if (tags.EndsWith(" "))
                {
                    tags = tags.Remove(tags.Length - 2, 1);
                }
                tagsSend.Add(tags);
            }
            TagsInfo tmpTags = new TagsInfo();
            tmpTags.ResourceId = ResourceId;
            tmpTags.tags = new List<string>();
            tmpTags.tags = tagsSend;

            HttpWebRequest tagrequest = WebRequest.Create(dashboardUrlBase + "resourcelist/" + ResourceId) as HttpWebRequest;
            tagrequest.Method = "POST";
            tagrequest.ContentType = "text/json";
            try
            {
                using (var streamWriter = new StreamWriter(tagrequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(tmpTags);

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var httpResponse = (HttpWebResponse)tagrequest.GetResponse();
            }
            catch (Exception ex)
            {
                lnkSaveFileInfo.Text = ex.ToString();
            }
            //end of tags

            //now it has URL
            string url = "";
            if (txtWebUrl.Text != "" && txtWebUrl.Text != " ")
            {
                if (!txtWebUrl.Text.ToLower().StartsWith("http://") && !txtWebUrl.Text.ToLower().StartsWith("https://"))
                    url = "http://" + txtWebUrl.Text.ToLower();
                else
                    url = txtWebUrl.Text.ToLower();
            }
            else
            {
                Span2.Text = "No information has been added, please add information and try again.";
                return;
            }
            HttpWebRequest urlRequest = WebRequest.Create(dashboardUrlBase + "resourceupload/" + ResourceId + "/website") as HttpWebRequest;
            urlRequest.ContentType = "text/json";
            urlRequest.Method = "POST";
            try
            {
                using (var streamWriter = new StreamWriter(urlRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(url);

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var httpResponse = (HttpWebResponse)urlRequest.GetResponse();
            }
            catch (Exception ex)
            {
                lnkSaveFileInfo.Text = ex.ToString();
                return;
            }
            //end of url
            divUploadPreviewImage.Visible = true;
            divWebsiteUpload.Visible = false;
            hidResourceId.Value = ResourceId.ToString();
        }