Ejemplo n.º 1
0
        public string addImage(IEnumerable<HttpPostedFileBase> Images)
        {
            foreach (HttpPostedFileBase image in Images)
            {
                if (image != null)
                {
                    try
                    {
                        FilesService fs = new FilesService();
                        //Original
                        string file_name = "";
                        file_name = (fs.RandomString() + "external-" + image.FileName).Replace(" ", "-");


                        System.Drawing.Image web_image = System.Drawing.Image.FromStream(image.InputStream);

                        //save Original Image
                        ImageService.SaveImage((System.Drawing.Image)web_image.Clone(), file_name, 0, 0, "/Images/ckuploades/");

                        //LOGI.Models.Image final_img = new LOGI.Models.Image() { URL = "/Images/ckuploades/" + file_name };
                        //Update the DB value
                        //DbContext.Images.Add(final_img);
                        //DbContext.SaveChanges();
                        return "/Images/ckuploades/" + file_name;
                    }
                    catch (Exception ex)
                    {
                        return "";
                    }
                }
            }
            return "";
        }
Ejemplo n.º 2
0
        public ActionResult Index(IEnumerable<HttpPostedFileBase> PDF)
        {
            ViewBag.MainNav = Navigator.Main.DONATE;

            if (ModelState.IsValid)
            {
                SectionVariable donate_pdf = variabeService.GetVariableByKey("DonatePDF");

                if (PDF != null && PDF.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();

                    if (donate_pdf != null)
                        fs.DeleteFile(donate_pdf.Value);

                    string file_url = fs.SaveFiles(PDF);

                    if(variabeService.AddUpdateVariable("DonatePDF", file_url) > 0)
                    {
                        TempData["SuccessMessage"] = "File Updated Successfully";
                        return RedirectToAction("Index");
                    }
                    else
                        TempData["ErrorMessage"] = "File Failed to Updated";
                }

            }
            return View();
        }
Ejemplo n.º 3
0
        public bool DeleteExpert(int id)
        {
            Expert a = DbContext.Experts.Where(aa => aa.ID == id).FirstOrDefault();

            if (a == null)
                return false;
            
            

            try
            {
                if (a.ResumeURL != null && a.ResumeURL != "")
                {
                    FilesService fs = new FilesService();
                    fs.DeleteFile(a.ResumeURL);
                }

                DbContext.Experts.Remove(a);

                DbContext.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 4
0
        public int AppplyAsExpert(Expert expert, IEnumerable<HttpPostedFileBase> resume = null)
        {
            expert.ApplyDate = DateTime.Now;

            DbContext.Experts.Add(expert);
            try
            {
                DbContext.SaveChanges();

                if (resume != null && resume.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();

                    string file_url = fs.SaveFiles(resume);
                    expert.ResumeURL = file_url;
                }
                DbContext.SaveChanges();

                return expert.ID;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 5
0
        public int AppplyToVacancy(int vacancy_id, VacancyApplication application, IEnumerable<HttpPostedFileBase> resume = null)
        {
            Vacancy vacancy = DbContext.Vacancies.Where(v => v.ID == vacancy_id).FirstOrDefault();

            if (vacancy == null)
                return -1;

            if (vacancy.VacancyApplications == null)
                vacancy.VacancyApplications = new List<VacancyApplication>();

            application.ApplyDate = DateTime.Now;

            vacancy.VacancyApplications.Add(application);
            try
            {
                DbContext.SaveChanges();

                if (resume != null && resume.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();

                    string file_url = fs.SaveFiles(resume);
                    application.ResumeURL = file_url;
                }
                DbContext.SaveChanges();

                return application.ID;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 6
0
        public bool DeleteVacancyApplication(int id)
        {
            VacancyApplication va = DbContext.VacancyApplications.Where(v => v.ID == id).FirstOrDefault();

            if (va == null)
                return false;

            try
            {
                if(va.ResumeURL !=null && va.ResumeURL != "" )
                {
                    FilesService fs = new FilesService();
                    fs.DeleteFile(va.ResumeURL);
                }

                DbContext.VacancyApplications.Remove(va);
                DbContext.SaveChanges();
                return true;
            }catch(Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 7
0
        public int UpdateKeyIssue(KeyIssue keyissue, List<string> ArabicTags, List<string> EnglishTags, IEnumerable<HttpPostedFileBase> Images = null, IEnumerable<HttpPostedFileBase> Files = null,List<int> Countries = null)
        {
            KeyIssue A = DbContext.KeyIssues.Where(a => a.ID == keyissue.ID).Include(a => a.Tags).Include(a=> a.Countries).FirstOrDefault();

            if (A == null)
                return -1;

            A.AuthorID = keyissue.AuthorID;
            A.Description = keyissue.Description;
            A.FeatureVideoLink = keyissue.FeatureVideoLink;
            A.FriendlyURL = keyissue.FriendlyURL;
            A.IsOnline = keyissue.IsOnline;
            A.MetaDescription = keyissue.MetaDescription;
            A.MetaTitle = keyissue.MetaTitle;
            A.PublishDate = keyissue.PublishDate;
            A.SourceID = keyissue.SourceID;
            A.Title = keyissue.Title;
            A.TopicID = keyissue.TopicID;
            A.IsFeatured = keyissue.IsFeatured;
            A.InScroller = keyissue.InScroller;
            A.TypeID = keyissue.TypeID;
            A.OriginalId = keyissue.OriginalId;
            A.Language = keyissue.Language;
            A.IsHomeVideoFeatured = keyissue.IsHomeVideoFeatured;

            try
            {
                foreach (Tag tag in A.Tags.ToList())
                    DbContext.Tags.Remove(tag);

                A.Tags = new List<Tag>();
                if (ArabicTags != null)
                    foreach (string t in ArabicTags)
                        A.Tags.Add(new Tag() { Name = t, Language = "ar" });
                if (EnglishTags != null)
                    foreach (string t in EnglishTags)
                        A.Tags.Add(new Tag() { Name = t, Language = "en" });
                DbContext.SaveChanges();

                foreach (Country country in A.Countries.ToList())
                    A.Countries.Remove(country);

                if (Countries != null)
                {
                    A.Countries = new List<Country>();
                    foreach (int c in Countries)
                    {
                        Country country = DbContext.Countries.Where(cc => cc.ID == c).FirstOrDefault();
                        if (country != null)
                            A.Countries.Add(country);
                    }
                }
                DbContext.SaveChanges();

                if (A.ID > 0 && Images != null && Images.Where(i => i != null).Count() > 0)
                {
                    if (A.FeatureImageURL != null && A.FeatureImageURL != "")
                    {
                        ImageService.DeleteImage(HttpContext.Current.Server.MapPath("~" + A.FeatureImageURL));
                        foreach (ImageSize IS in LogiConfig.KeyIssuesImageSizes)
                            ImageService.DeleteImage(HttpContext.Current.Server.MapPath("~" + A.FeatureImageURL), IS.Width.ToString(), IS.Height.ToString());
                    }
                    AddKeyIssueImages(A.ID, Images);
                }

                if (Files != null && Files.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();
                    if (A.FileURL != null && A.FileURL != "")
                    {
                        fs.DeleteFile(A.FileURL);
                    }

                    string file_url = fs.SaveFiles(Files);
                    A.FileURL = file_url;
                    DbContext.SaveChanges();
                }

                return A.ID;
            }
            catch (Exception ex)
            {
                return -1;
            }

        }
Ejemplo n.º 8
0
        public int AddKeyIssue(KeyIssue keyissue, List<string> ArabicTags, List<string> EnglishTags, IEnumerable<HttpPostedFileBase> Images = null, IEnumerable<HttpPostedFileBase> Files = null,List<int> Countries = null)
        {
            DbContext.KeyIssues.Add(keyissue);
            try
            {
                //add tags
                keyissue.Tags = new List<Tag>();
                if (ArabicTags != null)
                    foreach (string t in ArabicTags)
                        keyissue.Tags.Add(new Tag() { Name = t, Language = "ar" });

                if (EnglishTags != null)
                    foreach (string t in EnglishTags)
                        keyissue.Tags.Add(new Tag() { Name = t, Language = "en" });

                if(Countries !=null)
                {
                    keyissue.Countries = new List<Country>();
                    foreach(int c in Countries)
                    {
                        Country country = DbContext.Countries.Where(cc=> cc.ID == c).FirstOrDefault();
                        if (country != null)
                            keyissue.Countries.Add(country);
                    }
                }

                DbContext.SaveChanges();

                if (keyissue.ID > 0 && Images != null && Images.Count() > 0 && Images.Where(i => i != null).Count() > 0)
                {
                    AddKeyIssueImages(keyissue.ID, Images);
                }

                if (Files != null && Files.Where(f => f != null).Count() > 0)
                {
                    FilesService fs = new FilesService();

                    string file_url = fs.SaveFiles(Files);
                    keyissue.FileURL = file_url;
                }
                DbContext.SaveChanges();

                return keyissue.ID;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 9
0
        public int UpdateReport(FinancialReportViewModel report, IEnumerable<HttpPostedFileBase> Files = null)
        {
            FinancialReport FR = DbContext.FinancialReports.Where(f => f.ID == report.ID).Include(a=> a.FinancialReportEntries).FirstOrDefault();

            if (FR == null)
                return -1;

            FR.Expences = report.ExpencesEntries.Sum(a=> a.Value);
            FR.Funding = report.FundingEntries.Sum(a => a.Value);
            FR.Year = report.Year;

            
            foreach (FinancialReportEntry e in FR.FinancialReportEntries.ToList())
                DbContext.FinancialReportEntries.Remove(e);

            FR.FinancialReportEntries = new List<FinancialReportEntry>();

            foreach(FinancialReportEntry fe in report.ExpencesEntries.Where(a=> a.Value != 0))
                FR.FinancialReportEntries.Add(fe);

            foreach (FinancialReportEntry fe in report.FundingEntries.Where(a => a.Value != 0))
                FR.FinancialReportEntries.Add(fe);
            //Update Entries
            if (Files.Where(f => f != null).Count() > 0)
            {
                FilesService fs = new FilesService();
                string file_url = fs.SaveFiles(Files);
                FR.FileURL = file_url;
            }

         

            DbContext.SaveChanges();
            return FR.ID;
        }
Ejemplo n.º 10
0
        public int AddReport(FinancialReportViewModel report, IEnumerable<HttpPostedFileBase> Files = null)
        {
            FinancialReport FR = new FinancialReport();

            FR.Expences = report.ExpencesEntries.Sum(a => a.Value);
            FR.Funding = report.FundingEntries.Sum(a => a.Value);
            FR.Year = report.Year;

            FR.FinancialReportEntries = new List<FinancialReportEntry>();
          
            foreach (FinancialReportEntry fe in report.ExpencesEntries)
                FR.FinancialReportEntries.Add(fe);

            foreach (FinancialReportEntry fe in report.FundingEntries)
                FR.FinancialReportEntries.Add(fe);
            //Update Entries

            if (Files.Where(f => f != null).Count() > 0)
            {
                FilesService fs = new FilesService();
                string file_url = fs.SaveFiles(Files);
                FR.FileURL = file_url;
            }

            DbContext.FinancialReports.Add(FR);
            DbContext.SaveChanges();
            return FR.ID;
        }
Ejemplo n.º 11
0
        public ActionResult Index(IEnumerable<HttpPostedFileBase> registration, IEnumerable<HttpPostedFileBase> giftAcceptance, IEnumerable<HttpPostedFileBase> bylaws, IEnumerable<HttpPostedFileBase> whitepaper, IEnumerable<HttpPostedFileBase> whitepaperAr)
        {
            ViewBag.MainNav = Navigator.Main.ABOUT;
            ViewBag.SubNav = Navigator.Sub.OFFICIALDOC;

            if (ModelState.IsValid)
            {
                try
                { 
                    SectionVariable R_pdf = variabeService.GetVariableByKey("RegistrationPDF");

                    if (registration != null && registration.Where(f => f != null).Count() > 0)
                    {
                        FilesService fs = new FilesService();

                        if (R_pdf != null)
                            fs.DeleteFile(R_pdf.Value);

                        string file_url = fs.SaveFiles(registration);

                        variabeService.AddUpdateVariable("RegistrationPDF", file_url);
                    }

                    SectionVariable B_pdf = variabeService.GetVariableByKey("ByLawsPDF");

                    if (bylaws != null && bylaws.Where(f => f != null).Count() > 0)
                    {
                        FilesService fs = new FilesService();

                        if (B_pdf != null)
                            fs.DeleteFile(B_pdf.Value);

                        string file_url = fs.SaveFiles(bylaws);

                        variabeService.AddUpdateVariable("ByLawsPDF", file_url);
                    }


                    SectionVariable W_pdf = variabeService.GetVariableByKey("WhitePaperPDF");

                    if (whitepaper != null && whitepaper.Where(f => f != null).Count() > 0)
                    {
                        FilesService fs = new FilesService();

                        if (W_pdf != null)
                            fs.DeleteFile(W_pdf.Value);

                        string file_url = fs.SaveFiles(whitepaper);

                        variabeService.AddUpdateVariable("WhitePaperPDF", file_url);
                    }

                    SectionVariable W_pdf_ar = variabeService.GetVariableByKey("WhitePaperPDFAr");

                    if (whitepaperAr != null && whitepaperAr.Where(f => f != null).Count() > 0)
                    {
                        FilesService fs = new FilesService();

                        if (W_pdf_ar != null)
                            fs.DeleteFile(W_pdf_ar.Value);

                        string file_url = fs.SaveFiles(whitepaperAr);

                        variabeService.AddUpdateVariable("WhitePaperPDFAr", file_url);
                    }

                    SectionVariable A_pdf = variabeService.GetVariableByKey("GiftAcceptancePolicy");

                    if (giftAcceptance != null && giftAcceptance.Where(f => f != null).Count() > 0)
                    {
                        FilesService fs = new FilesService();

                        if (A_pdf != null)
                            fs.DeleteFile(A_pdf.Value);

                        string file_url = fs.SaveFiles(giftAcceptance);

                        variabeService.AddUpdateVariable("GiftAcceptancePolicy", file_url);
                    }

                    TempData["SuccessMessage"] = "Files Updated Successfully";
                    return RedirectToAction("Index");
                }
                catch(Exception ex)
                {
                    TempData["ErrorMessage"] = "Files Failed to Updated";
                }
            }
            return View();
        }