Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["success"] != null)
     {
         Toast.success(this, Session["success"].ToString());
         Session["success"] = null;
     }
     if (Session["error"] != null)
     {
         Toast.error(this, Session["error"].ToString());
         Session["error"] = null;
     }
     if (!Page.IsPostBack)
     {
         List <BL.service.Service> services = new BL.service.Service().OrderedSelectAll("favs");
         topServiceFavs.DataSource = services;
         topServiceFavs.DataBind();
         services = new BL.service.Service().OrderedSelectAll("views");
         topViewServ.DataSource = services;
         topViewServ.DataBind();
     }
     if (topServiceFavs.Items.Count < 1)
     {
         servFavErr.Visible = true;
     }
     if (topViewServ.Items.Count < 1)
     {
         servViewsSection.Attributes["class"] = servViewsSection.Attributes["class"] + " d-flex align-items-center";
         servViewsDiv.Attributes["class"]     = "flex-fill mt-4";
         servViewsDiv.Attributes["style"]     = "z-index-1;";
         servViewErr.Visible = true;
     }
 }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["success"] != null)
     {
         Toast.success(this, Session["success"].ToString());
         Session["success"] = null;
     }
     if (Session["error"] != null)
     {
         Toast.error(this, Session["error"].ToString());
         Session["error"] = null;
     }
     if (!Page.IsPostBack)
     {
         List <BL.service.Service> services = new BL.service.Service().SelectAll();
         if (services.Count < 1)
         {
             LbErr.Visible = true;
         }
         servList.DataSource = services;
         servList.DataBind();
         if (Session["uid"] != null)
         {
             LblUid.Value = Session["uid"].ToString();
         }
     }
 }
Exemple #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["success"] != null)
     {
         Toast.success(this, Session["success"].ToString());
         Session["success"] = null;
     }
     if (Session["error"] != null)
     {
         Toast.error(this, Session["error"].ToString());
         Session["error"] = null;
     }
     if (!Page.IsPostBack)
     {
         if (Session["uid"] != null)
         {
             LblUid.Text = Session["uid"].ToString();
             List <BL.service.Service> uservices = new BL.service.Service().SelectByUid(LblUid.Text);
             if (uservices.Count < 1)
             {
                 LbErr.Visible = true;
             }
             managelist.DataSource = uservices;
             managelist.DataBind();
         }
         else
         {
             Session["error"] = "Please log in to manage services";
             Response.Redirect("~/Views/auth/login/aspx");
         }
     }
 }
Exemple #4
0
 protected void reqlist_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "viewprofile")
     {
         Response.Redirect("~/Views/profile/view.aspx?uid=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "pay")
     {
         string   idList = e.CommandArgument.ToString();
         string[] ids    = idList.Split(',');
         Response.Redirect("~/Views/service/payment.aspx?sid=" + ids[0] + "&jid=" + ids[1]);
     }
     if (e.CommandName == "cancel")
     {
         string   idList = e.CommandArgument.ToString();
         string[] ids    = idList.Split(',');
         User     curr   = new User().SelectById(LblUid.Value);
         List <BL.service.Service> service = new BL.service.Service().SelectById(ids[2]);
         int result = new Jobs().UpdateStatus(ids[0], "cancelled");
         if (result == 0)
         {
             Toast.error(this, "An error occured while cancelling request");
         }
         else
         {
             Notification notif = new Notification(int.Parse(LblUid.Value), curr.username, int.Parse(ids[2]), service[0].name, ids[1], "job_cancel");
             notif.AddNotif();
             List <Jobs> jobs = new Jobs().SelectByCid(LblUid.Value);
             reqlist.DataSource = jobs;
             reqlist.DataBind();
             Toast.success(this, "Request cancelled");
         }
     }
 }
Exemple #5
0
        protected void serviceview_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HiddenField providerField         = (HiddenField)e.Item.FindControl("LblFid");
            HiddenField idField               = (HiddenField)e.Item.FindControl("servId");
            User        freelancer            = new User().SelectById(providerField.Value);
            List <BL.service.Service> service = new BL.service.Service().SelectById(idField.Value);

            Image img = e.Item.FindControl("poster") as Image;

            string dirPath = "~/Content/uploads/services/" + providerField.Value + "/";

            if (File.Exists(Server.MapPath(dirPath) + service[0].Id + ".png"))
            {
                img.ImageUrl = Page.ResolveUrl(dirPath + service[0].Id + ".png");
            }

            img = e.Item.FindControl("profpic") as Image;

            dirPath = "~/Content/uploads/profile/" + providerField.Value + "/";
            if (File.Exists(Server.MapPath(dirPath) + "profilePic.png"))
            {
                img.ImageUrl = Page.ResolveUrl(dirPath + "profilePic.png");
            }

            img = e.Item.FindControl("banner") as Image;

            if (File.Exists(Server.MapPath(dirPath) + "banner.png"))
            {
                img.ImageUrl = Page.ResolveUrl(dirPath + "banner.png");
            }

            var email = e.Item.FindControl("email") as Label;

            email.Text = freelancer.email;
        }
Exemple #6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string categories = "";
            int    count      = 0;

            foreach (ListItem item in cblCat.Items)
            {
                if (item.Selected)
                {
                    categories += item.Value + " ";
                    count++;
                }
            }

            if (count == 0)
            {
                Toast.error(this, "Please check at least one category");
            }
            else if (ValidateInput(tbName.Text, tbDesc.Text, tbPrice.Text))
            {
                categories.Remove(categories.Length - 1);
                string  name   = tbName.Text;
                string  desc   = tbDesc.Text;
                decimal price  = decimal.Parse(tbPrice.Text);
                bool    valid  = true;
                int     result = 0;

                User curruser = new User().SelectById(LblUid.Text);
                BL.service.Service service = new BL.service.Service(name, desc, price, categories, curruser.Id, curruser.username);

                if (upPoster.HasFile)
                {
                    valid = storeTemp();
                }

                if (valid)
                {
                    result = service.AddService();
                }

                if (upPoster.HasFile)
                {
                    storeFile(result.ToString());
                }

                if (result == 0)
                {
                    Toast.error(this, "Error occured while adding service");
                }
                else
                {
                    Session["success"] = "Service added";
                    Response.Redirect("~/Views/service/manage.aspx");
                }
            }
        }
Exemple #7
0
        protected void projects_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            User        currUser    = getCurrUser();
            HiddenField projIdField = e.Item.FindControl("projectId") as HiddenField;

            string projectCoverUrl = "~/Content/uploads/profile/" + currUser.Id.ToString() + "/projects/" + projIdField.Value + ".png";
            string pathToFile      = Server.MapPath(projectCoverUrl);

            if (System.IO.File.Exists(pathToFile))
            {
                Image projImg = e.Item.FindControl("projCover") as Image;
                projImg.ImageUrl = Page.ResolveUrl(projectCoverUrl);
                projImg          = e.Item.FindControl("projModalCover") as Image;
                projImg.ImageUrl = Page.ResolveUrl(projectCoverUrl);
            }

            string profilePicUrl = "~/Content/uploads/profile/" + currUser.Id.ToString() + "/profilePic.png";

            pathToFile = Server.MapPath(profilePicUrl);
            if (System.IO.File.Exists(pathToFile))
            {
                Image profilePic = e.Item.FindControl("profilePic") as Image;
                profilePic.ImageUrl = Page.ResolveUrl(profilePicUrl);
                profilePic          = e.Item.FindControl("modal_profilePic") as Image;
                profilePic.ImageUrl = Page.ResolveUrl(profilePicUrl);
            }

            Label LblUsername = e.Item.FindControl("modal_username") as Label;

            LblUsername.Text = currUser.username;
            LblUsername      = e.Item.FindControl("modal_username2") as Label;
            LblUsername.Text = currUser.username;
            LblUsername      = e.Item.FindControl("formUsername") as Label;
            LblUsername.Text = currUser.username;

            Repeater servicerepeater = e.Item.FindControl("userServices") as Repeater;
            List <BL.service.Service> userServices = new BL.service.Service().SelectByUid(currUser.Id.ToString());

            servicerepeater.DataSource = userServices;
            servicerepeater.DataBind();
            if (userServices.Count < 1)
            {
                e.Item.FindControl("noService").Visible = true;
            }

            Repeater           commentrepeater = e.Item.FindControl("comments") as Repeater;
            List <PortComment> comments        = new PortComment().SelectByPid(int.Parse(projIdField.Value));

            commentrepeater.DataSource = comments;
            commentrepeater.DataBind();
            if (comments.Count < 1)
            {
                e.Item.FindControl("noComments").Visible = true;
            }
        }
Exemple #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["id"] != null)
     {
         if (!Page.IsPostBack)
         {
             if (Session["uid"] != null)
             {
                 LblUid.Text = Session["uid"].ToString();
                 User user = new User().SelectById(LblUid.Text);
                 if (user.type == "client")
                 {
                     Session["error"] = "You need to be a service provider to edit a service";
                     Response.Redirect("~/Views/index.aspx");
                 }
                 List <BL.service.Service> service = new BL.service.Service().SelectById(Request.QueryString["id"]);
                 if (user.Id != service[0].uid)
                 {
                     Session["error"] = "You are not allowed to edit other's services";
                     Response.Redirect("~/Views/profile/index.aspx");
                 }
                 tbName.Text  = service[0].name;
                 tbDesc.Text  = service[0].desc;
                 tbPrice.Text = service[0].price.ToString();
                 string posterPath = "~/Content/uploads/services/" + LblUid.Text + "/" + service[0].Id + ".png";
                 if (File.Exists(Server.MapPath(posterPath)))
                 {
                     poster.ImageUrl = Page.ResolveUrl(posterPath);
                 }
                 string[] categories = service[0].categories.Split(' ');
                 foreach (ListItem item in cblCat.Items)
                 {
                     foreach (string category in categories)
                     {
                         if (category == item.Value)
                         {
                             item.Selected = true;
                         }
                     }
                 }
             }
             else
             {
                 Session["error"] = "Please log in to edit service";
                 Response.Redirect("~/Views/auth/login.aspx");
             }
         }
     }
     else
     {
         Session["error"] = "Please select a service to edit";
         Response.Redirect("~/Views/service/manage.aspx");
     }
 }
Exemple #9
0
        protected void serviceview_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "request")
            {
                string freelancerId = e.CommandArgument.ToString();
                string serviceId    = Request.QueryString["id"].ToString();
                List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId);
                User curruser   = new User().SelectById(LblUid.Value);
                User freelancer = new User().SelectById(freelancerId);
                Jobs existjob   = new Jobs().SelectByCidSid(curruser.Id.ToString(), service[0].Id.ToString());

                if (int.Parse(freelancerId) == curruser.Id)
                {
                    Session["error"] = "You cannot purchase your own service";
                    Response.Redirect("~/Views/service/servicelist.aspx");
                }

                if (curruser.type == "freelancer")
                {
                    Session["error"] = "Only clients are able to request services";
                    Response.Redirect("~/Views/service/servicelist.aspx");
                }

                if (existjob == null)
                {
                    TextBox tbRemark = (TextBox)e.Item.FindControl("tbRemarks");
                    Jobs    job      = new Jobs(int.Parse(LblUid.Value), int.Parse(freelancerId), int.Parse(serviceId), service[0].name, curruser.username, freelancer.username, tbRemark.Text, service[0].price);
                    int     result   = job.AddJob();

                    if (result == 0)
                    {
                        Session["error"] = "An error occured while requesting the service";
                        Response.Redirect("~/Views/service/servicelist.aspx");
                    }
                    else
                    {
                        Notification notif = new Notification(int.Parse(LblUid.Value), curruser.username, int.Parse(serviceId), service[0].name, freelancer.Id.ToString(), "job");
                        notif.AddNotif();
                        Session["success"] = "Service requested successfully, please wait for " + freelancer.username + "\\'s response";
                        Response.Redirect("~/Views/service/servicelist.aspx");
                    }
                }
                else
                {
                    Session["error"] = "You cannot request for this service until completion of previous request";
                    Response.Redirect("~/Views/service/servicelist.aspx");
                }
            }
            if (e.CommandName == "viewprofile")
            {
                Response.Redirect("~/Views/profile/view.aspx?id=" + e.CommandArgument.ToString());
            }
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["uid"] == null)
            {
                Session["error"] = "Unauthorized";
                Response.Redirect("~/Views/index.aspx");
            }
            else
            {
                StripeConfiguration.ApiKey = "sk_test_51Hnjg6K2AIXSM7wrvlwz0S8eQSrtxjb7irpnIhvWGSKSsbWJzUymiC3tHbwxYQCumbmK5gC06kRIw7wr1eHEpj6D00CDgHmOpO";
                currUserId = Session["uid"].ToString();
                User user       = new User().SelectById(currUserId);
                User freelancer = new User().SelectById(Request.QueryString["fid"].ToString());
                List <BL.service.Service> service = new BL.service.Service().SelectById(Request.QueryString["sid"].ToString());
                Customer        cust      = new Customer();
                Customer        freelance = new Customer();
                CustomerService serv      = new CustomerService();

                cust      = serv.Get(user.stripeId);
                freelance = serv.Get(freelancer.stripeId);

                string token      = Request.QueryString["token"].ToString();
                bool   tokenValid = new User().CheckTokenValid("payment", token, currUserId);

                if (tokenValid)
                {
                    Payment.pay(cust, freelance, service[0].price.ToString());
                    new Jobs().UpdateStatus(Request.QueryString["jid"].ToString(), "paid");
                    Notification notif = new Notification(user.Id, user.username, int.Parse(Request.QueryString["sid"].ToString()), service[0].name, freelancer.Id.ToString(), "job_paid");
                    notif.AddNotif();
                    Transaction trans = null;
                    trans = new Transaction(freelancer.username, service[0].name, "SGD", service[0].price, user.Id);
                    trans.AddTrans();
                    trans = new Transaction(user.username, service[0].name, "SGD", service[0].price, freelancer.Id);
                    trans.AddTrans();
                    Session["success"] = "Transaction successful";
                    Response.Redirect("~/Views/service/paymentList.aspx");
                }
                else
                {
                    Session["error"] = "Payment token is invalid or has expired";
                    Response.Redirect("~/Views/index.aspx");
                }
            }
        }
Exemple #11
0
 protected void topViewServ_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "viewprofile")
     {
         Response.Redirect("~/Views/profile/view.aspx?id=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "fav")
     {
         favourite(e.CommandArgument.ToString());
         List <BL.service.Service> services = new BL.service.Service().OrderedSelectAll("views");
         topViewServ.DataSource = services;
         topViewServ.DataBind();
     }
     if (e.CommandName == "view")
     {
         Response.Redirect("~/Views/service/index.aspx?id=" + e.CommandArgument.ToString());
     }
 }
Exemple #12
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            string categories = "";
            int    count      = 0;

            foreach (ListItem item in cblCat.Items)
            {
                if (item.Selected)
                {
                    categories += item.Value + " ";
                    count++;
                }
            }

            if (count == 0)
            {
                Toast.error(this, "Please check at least one category");
            }
            else if (ValidateInput(tbName.Text, tbDesc.Text, tbPrice.Text))
            {
                categories.Remove(categories.Length - 1);
                int Id = int.Parse(Request.QueryString["id"].ToString());
                List <BL.service.Service> curr = new BL.service.Service().SelectById(Id.ToString());
                bool valid = true;

                BL.service.Service service = new BL.service.Service();
                int result = service.UpdateService(tbName.Text, tbDesc.Text, decimal.Parse(tbPrice.Text), categories, Id);
                if (upPoster.HasFile)
                {
                    valid = storeFile(curr[0].Id.ToString());
                }
                if (result == 0 && valid)
                {
                    Toast.error(this, "An error occured while updating service");
                }
                else
                {
                    Session["success"] = "Service updated successfully";
                    Response.Redirect("~/Views/service/manage.aspx");
                }
            }
        }
Exemple #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["id"] != null)
     {
         if (!Page.IsPostBack)
         {
             List <BL.service.Service> service = new BL.service.Service().SelectById(Request.QueryString["id"].ToString());
             serviceview.DataSource = service;
             serviceview.DataBind();
         }
     }
     else
     {
         Session["error"] = "Please select a service to view";
         Response.Redirect("~/Views/service/servicelist.aspx");
     }
     if (Session["uid"] != null)
     {
         LblUid.Value = Session["uid"].ToString();
     }
 }
Exemple #14
0
 public void favourite(string sid)
 {
     if (Session["uid"] != null)
     {
         string                    currUserId = Session["uid"].ToString();
         List <string>             userFavs   = new Fav().SelectUserFavs(currUserId);
         List <BL.service.Service> serv       = new BL.service.Service().SelectById(sid);
         if (!userFavs.Contains(sid))
         {
             new BL.service.Service().Favourite(sid, serv[0].favs + 1);
             Fav fav    = new Fav(int.Parse(currUserId), int.Parse(sid));
             int result = fav.Add();
             if (result == 1)
             {
                 Toast.success(this, "Service favourited");
             }
             else
             {
                 Toast.error(this, "An error occured while favouriting service");
             }
         }
         else
         {
             new BL.service.Service().Favourite(sid, serv[0].favs - 1);
             int result = new Fav().Remove(int.Parse(currUserId), int.Parse(sid));
             if (result == 1)
             {
                 Toast.success(this, "Service unfavourited");
             }
             else
             {
                 Toast.error(this, "An error occured while unfavouriting service");
             }
         }
     }
     else
     {
         Toast.error(this, "You need to be logged in to favourite a service");
     }
 }
        protected void btnPay_Click(object sender, EventArgs e)
        {
            User   user = new User().SelectById(LblUid.Text);
            string sid  = Request.QueryString["sid"].ToString();
            List <BL.service.Service> service = new BL.service.Service().SelectById(sid);
            User freelancer = new User().SelectById(service[0].uid.ToString());

            string price = servprice.InnerHtml.Replace("$", string.Empty);
            string token = Auth.generateToken();

            new User().UpdatePaymentToken(user.Id.ToString(), Auth.encrypt(token, Convert.FromBase64String(user.IV)), (DateTime.Now.AddHours(1).Ticks).ToString());
            string link = "https://localhost:44309/Views/service/paymentSuccess.aspx?sid=" + sid + "&fid=" + freelancer.Id + "&jid=" + Request.QueryString["jid"].ToString() + "&token=" + token;

            Email.Send(user.email, user.username, "Outsource Service payment",
                       "<p>You are receiving this because you (or someone else) is trying to pay for a service on Outsource.</p>" +
                       "<p>Service Name: " + service[0].name + "</p>" +
                       "<p>Price: $" + service[0].price + "</p>" +
                       "<p>Please click on the following link or paste it into your browser to complete the payment.</p>" +
                       "<a href='" + link + "'>" + link + "</a>" +
                       "<p>If you did not request this, please ignore this email and your balance will not be deducted.</p>");
            Toast.success(this, "A confirmation email has been sent to your email account");
        }
Exemple #16
0
        protected void joblist_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "viewprofile")
            {
                Response.Redirect("~/Views/profile/view.aspx?id=" + e.CommandArgument.ToString());
            }

            if (e.CommandName == "accept")
            {
                string   idList     = e.CommandArgument.ToString();
                string[] ids        = idList.Split(',');
                User     freelancer = new User().SelectById(LblUid.Text);
                List <BL.service.Service> service = new BL.service.Service().SelectById(ids[1]);
                int result = new Jobs().UpdateStatus(ids[0], "accepted");
                if (result == 0)
                {
                    Toast.error(this, "An error occured while accepting job");
                }
                else
                {
                    Notification notif = new Notification(int.Parse(LblUid.Text), freelancer.username, int.Parse(ids[1]), service[0].name, ids[2], "request");
                    notif.AddNotif();
                    bind();
                    Toast.success(this, "Job accepted");
                }
            }

            if (e.CommandName == "reject")
            {
                string   idList     = e.CommandArgument.ToString();
                string[] ids        = idList.Split(',');
                User     freelancer = new User().SelectById(LblUid.Text);
                List <BL.service.Service> service = new BL.service.Service().SelectById(ids[1]);
                int result = new Jobs().UpdateStatus(ids[0], "cancelled");
                if (result == 0)
                {
                    Toast.error(this, "An error occured while cancelling job");
                }
                else
                {
                    Notification notif = new Notification(int.Parse(LblUid.Text), freelancer.username, int.Parse(ids[1]), service[0].name, ids[2], "req_cancel");
                    notif.AddNotif();
                    bind();
                    Toast.success(this, "Job cancelled");
                }
            }

            if (e.CommandName == "submit")
            {
                string   idList     = e.CommandArgument.ToString();
                string[] ids        = idList.Split(',');
                User     freelancer = new User().SelectById(LblUid.Text);
                List <BL.service.Service> service = new BL.service.Service().SelectById(ids[1]);
                int result = new Jobs().UpdateStatus(ids[0], "done");
                if (result == 0)
                {
                    Toast.error(this, "An error occured while completing job");
                }
                else
                {
                    Notification notif = new Notification(int.Parse(LblUid.Text), freelancer.username, int.Parse(ids[1]), service[0].name, ids[2], "complete");
                    notif.AddNotif();
                    bind();
                    Toast.success(this, "Job completed");
                }
            }
        }
Exemple #17
0
        protected void favList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "view")
            {
                string serviceId = e.CommandArgument.ToString();
                List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId);
                BL.service.Service        curr    = new BL.service.Service();
                curr.UpdateViews(serviceId, service[0].views + 1);
                Response.Redirect("~/Views/service/index.aspx?id=" + serviceId);
            }
            if (e.CommandName == "favourite")
            {
                if (string.IsNullOrEmpty(LblUid.Text))
                {
                    Session["error"] = "Please log in to favourite a service";
                    Response.Redirect("~/Views/auth/login.aspx");
                }

                string serviceId = e.CommandArgument.ToString();
                List <BL.service.Service> service = new BL.service.Service().SelectById(serviceId);
                BL.service.Service        curr    = new BL.service.Service();
                User curruser   = getCurrUser();
                User freelancer = new User().SelectById(service[0].uid.ToString());

                List <string> userfavs = new Fav().SelectUserFavs(LblUid.Text);

                if (!userfavs.Contains(serviceId))
                {
                    int servres = curr.Favourite(serviceId, service[0].favs + 1);
                    Fav fav     = new Fav(int.Parse(LblUid.Text), int.Parse(serviceId));
                    int favres  = fav.Add();
                    if (favres == 1 && servres == 1)
                    {
                        Notification notif = new Notification(int.Parse(LblUid.Text), curruser.username, service[0].Id, service[0].name, freelancer.Id.ToString(), "fav");
                        notif.AddNotif();
                        Toast.success(this, "Service favourited");
                    }
                    else
                    {
                        Toast.error(this, "An error occured while favouriting the service");
                    }
                }
                else
                {
                    int servres = curr.Favourite(serviceId, service[0].favs - 1);
                    Fav fav     = new Fav();
                    int favres  = fav.Remove(int.Parse(LblUid.Text), int.Parse(serviceId));
                    if (favres == 1 && servres == 1)
                    {
                        Toast.success(this, "Service unfavourited");
                    }
                    else
                    {
                        Toast.error(this, "An error occured while unfavouriting the service");
                    }
                }
                List <string>             userFavs = new Fav().SelectUserFavs(LblUid.Text);
                List <BL.service.Service> servFavs = new List <BL.service.Service>();
                foreach (string favs in userFavs)
                {
                    List <BL.service.Service> serv = new BL.service.Service().SelectById(favs);
                    servFavs.Add(serv[0]);
                }
                favList.DataSource = servFavs;
                favList.DataBind();
            }
        }
Exemple #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["success"] != null)
            {
                Toast.success(this, Session["success"].ToString());
                Session["success"] = null;
            }
            if (Session["error"] != null)
            {
                Toast.error(this, Session["error"].ToString());
                Session["error"] = null;
            }
            if (Session["uid"] != null)
            {
                LblUid.Text = Session["uid"].ToString();
                User user = getCurrUser();
                bio.InnerHtml          = user.bio;
                website.InnerHtml      = user.website;
                dob.InnerHtml          = user.birthday;
                gender.InnerHtml       = user.gender;
                location.InnerHtml     = user.location;
                occupation.InnerHtml   = user.occupation;
                email.InnerHtml        = user.email;
                currUsername.InnerHtml = user.username;

                string[]      social     = user.social.Split(',');
                List <string> socialList = new List <string>(social);
                twitter.HRef  = socialList[0];
                insta.HRef    = socialList[1];
                facebook.HRef = socialList[2];
                youtube.HRef  = socialList[3];
                deviant.HRef  = socialList[4];

                string[]      userSkills = user.skills.Split(',');
                List <string> skillList  = new List <string>();
                foreach (string skill in userSkills)
                {
                    if (skill != "")
                    {
                        skillList.Add(skill);
                    }
                }
                if (skillList.Count < 1)
                {
                    noskill.Visible = true;
                }
                skillsRepeater.DataSource = skillList;
                skillsRepeater.DataBind();

                if (user.type == "client")
                {
                    usertype.InnerHtml = "Client";
                }

                string dirPath = "~/Content/uploads/profile/" + LblUid.Text + "/";
                if (File.Exists(Server.MapPath(dirPath) + "banner.png"))
                {
                    userBanner.ImageUrl = Page.ResolveUrl(dirPath + "banner.png");
                }
                if (File.Exists(Server.MapPath(dirPath) + "profilePic.png"))
                {
                    userProfilePic.ImageUrl = Page.ResolveUrl(dirPath + "profilePic.png");
                }

                followers.InnerHtml      = user.followers.ToString();
                following.InnerHtml      = user.following.ToString();
                followerTitle.InnerHtml  = user.username + "'s followers";
                followingTitle.InnerHtml = user.username + "'s following";

                List <string>             userFavs = new Fav().SelectUserFavs(LblUid.Text);
                List <BL.service.Service> servFavs = new List <BL.service.Service>();
                foreach (string favs in  userFavs)
                {
                    List <BL.service.Service> service = new BL.service.Service().SelectById(favs);
                    servFavs.Add(service[0]);
                }
                List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text);
                servList.DataSource = services;
                servList.DataBind();
                favList.DataSource = servFavs;
                favList.DataBind();
                List <string> followingIds   = new Follow().SelectFollowing(LblUid.Text);
                List <User>   usersFollowing = new List <User>();
                foreach (string id in followingIds)
                {
                    User followingUser = new User().SelectById(id);
                    usersFollowing.Add(followingUser);
                }
                followingRepeater.DataSource = usersFollowing;
                followingRepeater.DataBind();
                List <string> followerIds   = new Follow().SelectFollowers(LblUid.Text);
                List <User>   usersFollower = new List <User>();
                foreach (string id in followerIds)
                {
                    User followerUser = new User().SelectById(id);
                    usersFollower.Add(followerUser);
                }
                followerRepeater.DataSource = usersFollower;
                followerRepeater.DataBind();
                if (followingRepeater.Items.Count == 0)
                {
                    noFollowing.Visible = true;
                }
                if (followerRepeater.Items.Count == 0)
                {
                    noFollower.Visible = true;
                }
                if (!Page.IsPostBack)
                {
                    List <Portfolio> portfolios = new Portfolio().SelectByUid(int.Parse(LblUid.Text));
                    projects.DataSource = portfolios;
                    projects.DataBind();
                    if (portfolios.Count < 1)
                    {
                        noProj.Visible = true;
                    }
                }
            }
            else
            {
                Session["error"] = "You need to be logged in to edit your profile";
                Response.Redirect("~/Views/index.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["sid"] == null)
            {
                Session["error"] = "Please select a service to pay for";
                Response.Redirect("~/Views/service/index.aspx");
            }
            if (Request.QueryString["jid"] == null)
            {
                Session["error"] = "Please select a request to pay for";
                Response.Redirect("~/Views/service/request.aspx");
            }
            else if (Session["uid"] == null)
            {
                Session["error"] = "Please log in to pay for service";
                Response.Redirect("~/Views/service/index.aspx");
            }
            else
            {
                LblUid.Text = Session["uid"].ToString();
                LblJid.Text = Request.QueryString["jid"].ToString();
                User user = new User().SelectById(LblUid.Text);
                if (user.type == "freelancer")
                {
                    Session["error"] = "You need to be a client to pay for a service";
                    Response.Redirect("~/Views/service/index.aspx");
                }
                Jobs job = new Jobs().SelectById(LblJid.Text);
                if (job.status == "paid")
                {
                    Session["error"] = "Request has already been paid";
                    Response.Redirect("~/Views/service/index.aspx");
                }
                client_email.InnerHtml = user.email;
                client_name.InnerHtml  = user.username;
                string dirPath = "~/Content/uploads/profile/" + user.Id + "/";
                if (System.IO.File.Exists(Server.MapPath(dirPath + "profilePic.png")))
                {
                    clientAvatar.ImageUrl = Page.ResolveUrl(dirPath + "profilePic.png");
                }
                if (System.IO.File.Exists(Server.MapPath(dirPath + "banner.png")))
                {
                    clientBanner.ImageUrl = Page.ResolveUrl(dirPath + "banner.png");
                }

                string sid = Request.QueryString["sid"].ToString();
                List <BL.service.Service> service = new BL.service.Service().SelectById(sid);
                servprice.InnerHtml = "$" + service[0].price.ToString();

                User freelancer = new User().SelectById(service[0].uid.ToString());
                freelance_email.InnerHtml = freelancer.email;
                freelance_name.InnerHtml  = freelancer.username;
                dirPath = "~/Content/uploads/profile/" + freelancer.Id + "/";
                if (System.IO.File.Exists(Server.MapPath(dirPath + "profilePic.png")))
                {
                    freelanceAvatar.ImageUrl = Page.ResolveUrl(dirPath + "profilePic.png");
                }
                if (System.IO.File.Exists(Server.MapPath(dirPath + "banner.png")))
                {
                    freelanceBanner.ImageUrl = Page.ResolveUrl(dirPath + "banner.png");
                }
            }
        }
Exemple #20
0
 protected void managelist_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "viewprofile")
     {
         Response.Redirect("~/Views/profile/index.aspx");
     }
     if (e.CommandName == "edit")
     {
         Response.Redirect("~/Views/service/edit.aspx?id=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "delete")
     {
         int result = new BL.service.Service().Delete(e.CommandArgument.ToString());
         if (result == 1)
         {
             Toast.success(this, "Service deleted successfully");
         }
         else
         {
             Toast.error(this, "An error occured while deleting service");
         }
         List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text);
         managelist.DataSource = services;
         managelist.DataBind();
     }
     if (e.CommandName == "view")
     {
         Response.Redirect("~/Views/service/index.aspx?id=" + e.CommandArgument.ToString());
     }
     if (e.CommandName == "favourite")
     {
         string serviceId = e.CommandArgument.ToString();
         List <BL.service.Service> service  = new BL.service.Service().SelectById(serviceId);
         BL.service.Service        curr     = new BL.service.Service();
         List <string>             userfavs = new Fav().SelectUserFavs(LblUid.Text);
         if (!userfavs.Contains(serviceId))
         {
             int servres = curr.Favourite(serviceId, service[0].favs + 1);
             Fav fav     = new Fav(int.Parse(LblUid.Text), int.Parse(serviceId));
             int favres  = fav.Add();
             if (favres == 1 && servres == 1)
             {
                 Toast.success(this, "Service favourited");
             }
             else
             {
                 Toast.error(this, "An error occured while favouriting the service");
             }
         }
         else
         {
             int servres = curr.Favourite(serviceId, service[0].favs - 1);
             Fav fav     = new Fav();
             int favres  = fav.Remove(int.Parse(LblUid.Text), int.Parse(serviceId));
             if (favres == 1 && servres == 1)
             {
                 Toast.success(this, "Service unfavourited");
             }
             else
             {
                 Toast.error(this, "An error occured while unfavouriting the service");
             }
         }
         List <BL.service.Service> services = new BL.service.Service().SelectByUid(LblUid.Text);
         managelist.DataSource = services;
         managelist.DataBind();
     }
 }