Пример #1
0
        public ActionResult DeletePost(FormCollection formCollection)
        {
            User user = new User();

            user = Session["User"] as IAProject_FreelancerSystem.Models.User;
            // Users
            if (Session["User"] != null)
            {
                if (user.role == "admin")
                {
                    return(RedirectToAction("Profile", "Dashboard"));
                }
                else if (user.role == "freelancer")
                {
                    return(RedirectToAction("Index", "Wall"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Wall"));
            }

            var jobID = formCollection["jobID"];

            new JobDB().Delete(jobID);

            List <Rate> jobs_rate = new RateDB().SelectAll();

            jobs_rate = jobs_rate.FindAll(r => r.jobID == Int32.Parse(jobID));
            for (int i = 0; i < jobs_rate.Count(); i++)
            {
                new RateDB().Delete(jobs_rate[i].rateID.ToString());
            }

            List <SavedJob> jobs_saved = new SavedJobDB().SelectAll();

            jobs_saved = jobs_saved.FindAll(r => r.jobID == Int32.Parse(jobID));
            for (int i = 0; i < jobs_saved.Count(); i++)
            {
                new SavedJobDB().Delete(jobs_saved[i].savedID.ToString());
            }

            List <Proposal> jobs_proposal = new ProposalsDB().SelectAll();

            jobs_proposal = jobs_proposal.FindAll(r => r.jobID == Int32.Parse(jobID));
            for (int i = 0; i < jobs_proposal.Count(); i++)
            {
                new ProposalsDB().Delete(jobs_proposal[i].propID.ToString());
            }

            return(RedirectToAction("MyPosts"));
        }
Пример #2
0
        public ActionResult receivedproposals()
        {
            User user = new User();

            user = Session["User"] as IAProject_FreelancerSystem.Models.User;
            // Users
            if (Session["User"] != null)
            {
                if (user.role == "admin")
                {
                    return(RedirectToAction("Profile", "Dashboard"));
                }
                else if (user.role == "freelancer")
                {
                    return(RedirectToAction("Index", "Wall"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Wall"));
            }

            // Get all User Job
            List <Job> jobList = new JobDB().SelectAll();

            jobList = jobList.FindAll(J => J.clientID == user.userID);

            // Get all Proposels
            List <Proposal> AllproposalList = new ProposalsDB().SelectAll();
            List <Proposal> proposalList    = new List <Proposal>();

            for (int i = 0; i < jobList.Count(); i++)
            {
                List <Proposal> temp = AllproposalList.FindAll(p => p.jobID == jobList[i].jobID);
                proposalList.AddRange(temp);
            }

            // Get all User that proposed
            List <User> userList = new List <User>();

            for (int i = 0; i < proposalList.Count(); i++)
            {
                userList.Add(new UserDB().SelectwithId(proposalList[i].freelancerID.ToString()));
            }

            // ** We need to send Jobs , Proposel for each Job, Client for each Proposel **
            // Return to View Profile
            ViewData["jobList"]      = jobList;
            ViewData["proposalList"] = proposalList;
            ViewData["userList"]     = userList;
            return(View("ReceivedProposals"));
        }