Ejemplo n.º 1
0
        public ActionResult Remove(string[] fileNames)
        {
            PictureRepository picRep = new PictureRepository();
            int NewPicID = picRep.GetLastPictureId(Convert.ToInt32(HttpContext.Session["ClientId"]));

            // The parameter of the Remove action must be called "fileNames"
            foreach (var fullName in fileNames)
            {
                var fileName = Path.GetFileName(fullName);
                var extention = fileName.Substring(fileName.IndexOf('.'));
                var newfilename = NewPicID.ToString() + extention;

                // Check if Path exsits
                string serverpath = Server.MapPath("~/Images/Client/" + HttpContext.Session["ClientId"].ToString() + "/Ads");
                if (!Directory.Exists(serverpath))
                {
                    Directory.CreateDirectory(serverpath);
                }

                var physicalPath = Path.Combine(Server.MapPath("~/Images/Client/" + HttpContext.Session["ClientId"].ToString() + "/Ads"), newfilename);

                // TODO: Verify user permissions
                if (System.IO.File.Exists(physicalPath))
                {
                    // The files are not actually removed in this demo
                    System.IO.File.Delete(physicalPath);

                    picRep.RemovePicture(NewPicID);
                }
            }
            // Return an empty string to signify success
            return Content("");
        }
Ejemplo n.º 2
0
        public List<Schoolsc> GetListSchools(int ClientId)
        {
            List<Schoolsc> list = new List<Schoolsc>();
            Schoolsc ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * from Schools WHERE ClientId = " + ClientId + " ORDER BY SchoolId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Schoolsc();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SchoolName = drI["SchoolName"].ToString();
                    ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            PictureRepository picRep = new PictureRepository();

            foreach (Schoolsc item in list)
            {
                if (item.PictureId != 0)
                {
                    item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl;
                    /*if (item.PicUrl.Contains("\\Images\\"))
                    {
                        string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\"));
                        path = path.Replace('\\', '/');
                        item.PicUrl = "http://www.netintercom.co.za" + path;
                    }*/
                }
            }

            return list;
        }
Ejemplo n.º 3
0
        public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
        {
            PictureRepository picRep = new PictureRepository();
            Functions functions = new Functions();
            // The Name of the Upload component is "attachments"
            int NewPicID = picRep.GetLastPictureId(Convert.ToInt32(HttpContext.Session["ClientId"]));
            NewPicID++;
            Picture ins = new Picture();

            foreach (var file in attachments)
            {
                // Some browsers send file names with full path. This needs to be stripped.
                var fileName = Path.GetFileName(file.FileName);
                var extention = fileName.Substring(fileName.IndexOf('.'));
                var newfilename = NewPicID.ToString() + extention;

                // Check if Path exsits
                string serverpath = Server.MapPath("~/Images/Client/" + HttpContext.Session["ClientId"].ToString() + "/Ads");
                if (!Directory.Exists(serverpath))
                {
                    Directory.CreateDirectory(serverpath);
                }

                var physicalPath = Path.Combine(Server.MapPath("~/Images/Client/" + HttpContext.Session["ClientId"].ToString() + "/Ads"), newfilename);

                //...Resize..
                Image original = Image.FromStream(file.InputStream, true, true);
                Image resized = functions.ResizeImage(original, new Size(500, 500));

                resized.Save(physicalPath, ImageFormat.Jpeg);

                string finalpath = physicalPath.ToString();
                finalpath = finalpath.Substring(finalpath.IndexOf("Images"));
                finalpath = finalpath.Replace('\\', '/');

                //...Save In DB...
                ins.PicUrl = Constants.HTTPPath + finalpath;
                ins.ClientId = Convert.ToInt32(HttpContext.Session["ClientId"]);

                ins = picRep.InsertPicture(ins);
            }
            // Return an empty string to signify success
            if (ins.PictureId != 0)
                return Json(new { status = ins.PictureId.ToString() }, "text/plain");
            else
                return Json(new { status = "0" }, "text/plain");
        }
Ejemplo n.º 4
0
        public void RemoveSchoolData(int ClientId)
        {
            PictureRepository picrep = new PictureRepository();
            picrep.RemoveSchoolPictures(ClientId);

            NotificationsRepository nrep = new NotificationsRepository();
            nrep.RemoveSchoolNotificationss(ClientId);

            EventRepository erep = new EventRepository();
            erep.RemoveSchoolEvents(ClientId);

            AdvertisementRepository arep = new AdvertisementRepository();
            arep.RemoveClientAdvertisement(ClientId);

            NewsRepository nerep = new NewsRepository();
            nerep.RemoveSchoolNewss(ClientId);

            ContactRepository crep = new ContactRepository();
            crep.RemoveSchoolContacts(ClientId);
        }
Ejemplo n.º 5
0
        public ActionResult _DeleteEvent(int id)
        {
            PictureRepository picRep = new PictureRepository();
            Event ins = EventRep.GetEvent(id);
            if (ins.PictureId != 0)
            {
                //...Get Picture...
                Picture pic = picRep.GetPicture(ins.PictureId);
                string path = pic.PicUrl.Substring(pic.PicUrl.IndexOf("/Images/") + 8);
                path = path.Replace('/', '\\');
                var finalpath = Path.Combine(Server.MapPath("~/Images"), path);
                System.IO.File.Delete(finalpath);
                bool picrem = picRep.RemovePicture(ins.PictureId);
            }

            bool ins2 = EventRep.RemoveEvent(id);

            //...Notify...
            string regIds = AppRep.GetAllRegIds(Convert.ToInt32(HttpContext.Session["ClientId"]));
            if (!regIds.Equals(""))
            {
                comrep.NewUpdateData(regIds, "CMD_DELEVENT", id.ToString());
            }

            //...Repopulate Grid...
            List<Event> lst = new List<Event>();
            lst = EventRep.GetListEvent(Convert.ToInt32(HttpContext.Session["ClientId"]));
            return View(new GridModel(lst));
        }
Ejemplo n.º 6
0
        public List<News> GetListNews(int ClientId)
        {
            List<News> list = new List<News>();
            News ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM News WHERE ClientId = " + ClientId + " ORDER BY NewsId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new News();
                    ins.NewsId = Convert.ToInt32(drI["NewsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.CategoryId = Convert.ToInt32(drI["CategoryId"]);
                    ins.SubCategoryId = Convert.ToInt32(drI["SubCategoryId"]);
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    ins.Title = drI["Title"].ToString();
                    ins.Body = drI["Body"].ToString();
                    ins.PostDate = Convert.ToDateTime(drI["PostDate"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            PictureRepository picRep = new PictureRepository();

            foreach(News item in list)
            {
                if (item.PictureId != 0)
                {
                    item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl;
                    /*if (item.PicUrl.Contains("\\Images\\"))
                    {
                        string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\"));
                        path = path.Replace('\\', '/');
                        item.PicUrl = "http://www.netintercom.co.za" + path;
                    }*/
                }
            }

            return list;
        }
Ejemplo n.º 7
0
        public List<Teams> GetListTeams(int ClientId)
        {
            List<Teams> list = new List<Teams>();
            Teams ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT t.*,sc.CategoryName,sch.* FROM Teams t inner join SportCategory sc on t.SportCategoryID = sc.SportCategoryId inner join Schools sch on t.SchoolId =sch.SchoolId  WHERE t.ClientId = " + ClientId + " ORDER BY t.TeamsId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Teams();
                    ins.TeamsId = Convert.ToInt32(drI["TeamsId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.Name = drI["Schoolabbreviation"].ToString();
                    ins.Age = drI["Age"].ToString();
                    ins.Ranks = drI["Ranks"].ToString();
                    ins.SportCategoryID = Convert.ToInt32(drI["SportCategoryID"]);
                    ins.sportcategory = drI["CategoryName"].ToString();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.schoolname = drI["SchoolName"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            PictureRepository picRep = new PictureRepository();

            foreach (Teams item in list)
            {
                if (item.PictureId != 0)
                {
                    item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl;
                    /*if (item.PicUrl.Contains("\\Images\\"))
                    {
                        string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\"));
                        path = path.Replace('\\', '/');
                        item.PicUrl = "http://www.netintercom.co.za" + path;
                    }*/
                }
            }
            return list;
        }