Exemplo n.º 1
0
        public ActionResult Create(Lazybones.Models.Job job)
        {
            // Creates a database reference to the user db
            LazinessSolutionsEntities6 jobDB  = new LazinessSolutionsEntities6();
            LazinessSolutionsEntities4 userDB = new LazinessSolutionsEntities4();
            var u = userDB.AspNetUsers.Find(User.Identity.GetUserId());

            if (User.Identity.IsAuthenticated)
            {
                job.Poster_Name  = User.Identity.GetUserId();
                job.Poster       = User.Identity.GetUserName();
                job.Status       = "Created";
                job.Poster_Phone = u.Mobile_Phone;
            }
            else
            {
                job.Poster_Name = "Invalid User";
            }
            if (job.Start_Time_Date == null)
            {
                job.Start_Time_Date = DateTime.Now;
            }
            job.Getter_Name = null;
            // Add the job passed to create post
            jobDB.Jobs.Add(job);
            // Save changes
            if (!ModelState.IsValid)
            {
                return(View(job));
            }
            jobDB.SaveChanges();
            return(RedirectToAction("Dashboard", "Home"));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int ID)
        {
            LazinessSolutionsEntities6 userProf = new LazinessSolutionsEntities6();
            var u = userProf.Jobs.Find(ID);

            u.Status = "Cancelled";
            userProf.SaveChanges();
            return(View("Details", u));
        }
Exemplo n.º 3
0
        public ActionResult MarkComplete(int ID)
        {
            LazinessSolutionsEntities6 userJob = new LazinessSolutionsEntities6();
            var u = userJob.Jobs.Find(ID);

            u.Status         = "Complete";
            u.Date_Completed = DateTime.Now;
            userJob.SaveChanges();

            LazinessSolutionsEntities4 userDeet = new LazinessSolutionsEntities4();
            var z     = userDeet.AspNetUsers.Find(u.Getter_Name);
            var count = z.Badge_Count + 1;

            z.Badge_Count = count;
            userDeet.SaveChanges();
            return(View("Details", u));
        }
Exemplo n.º 4
0
        public ActionResult MarkAsPaid(int ID)
        {
            LazinessSolutionsEntities6 userProf = new LazinessSolutionsEntities6();
            var u = userProf.Jobs.Find(ID);

            u.Payment_Complete = true;
            userProf.SaveChanges();

            string           AccountSid = "ACcd539f756b9224060b4e0568d0c614b3";
            string           AuthToken  = "d1dc9f49c5b32232aec0267fc582afcb";
            TwilioRestClient client;

            client = new TwilioRestClient(AccountSid, AuthToken);
            Message result = client.SendMessage(
                "+13132419747", "+1" + u.Getter_Phone, "Greetings, from Alfred! " + u.Title + "' has paid you for " + u.Title + ".");

            return(View("Details", u));
        }
Exemplo n.º 5
0
        public ActionResult Edit(Lazybones.Models.Job editedProfile)
        {
            LazinessSolutionsEntities6 dbContext = new LazinessSolutionsEntities6();

            Lazybones.Models.Job existingJob = dbContext.Jobs.Find(editedProfile.ID);
            existingJob.Title             = editedProfile.Title;
            existingJob.Description       = editedProfile.Description;
            existingJob.Start_Time_Date   = editedProfile.Start_Time_Date;
            existingJob.Expirey_Time_Date = editedProfile.Expirey_Time_Date;
            existingJob.Category          = editedProfile.Category;
            existingJob.Pay              = editedProfile.Pay;
            existingJob.Best_Bid         = editedProfile.Best_Bid;
            existingJob.Picture_Location = editedProfile.Picture_Location;
            existingJob.Date_Completed   = editedProfile.Date_Completed;
            existingJob.Getter_Name      = editedProfile.Getter_Name;
            existingJob.Status           = editedProfile.Status;
            existingJob.Payment_Complete = editedProfile.Payment_Complete;
            existingJob.Contact_By_Phone = editedProfile.Contact_By_Phone;
            existingJob.Contact_By_Email = editedProfile.Contact_By_Email;
            existingJob.Contact_By_Text  = editedProfile.Contact_By_Text;
            existingJob.Address          = editedProfile.Address;
            existingJob.City             = editedProfile.City;
            existingJob.Zip              = editedProfile.Zip;
            existingJob.State            = editedProfile.State;
            existingJob.Getter           = editedProfile.Getter;
            existingJob.Poster           = editedProfile.Poster;
            existingJob.Bid_Amount       = editedProfile.Bid_Amount;
            existingJob.Same_as_Home     = editedProfile.Same_as_Home;
            existingJob.Getter_Badges    = editedProfile.Getter_Badges;
            existingJob.Poster_Phone     = editedProfile.Poster_Phone;
            try
            {
                dbContext.SaveChanges();
                return(View("Details", existingJob));
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            return(View("Details", existingJob));
        }
Exemplo n.º 6
0
        public ActionResult Details(Lazybones.Models.Job editedProfile)
        {
            LazinessSolutionsEntities6 dbContext = new LazinessSolutionsEntities6();

            Lazybones.Models.Job existingJob = dbContext.Jobs.Find(editedProfile.ID);

            existingJob.Comment_History += "(" + User.Identity.GetUserName() + " " + DateTime.Now + ") " + existingJob.Comments + "\r \n " + editedProfile.Comments;
            existingJob.Comments         = "";
            try
            {
                dbContext.SaveChanges();
                return(View("Details", existingJob));
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            return(RedirectToAction("Dashboard", "Home"));
        }
Exemplo n.º 7
0
        public ActionResult SetGetter(int ID)
        {
            LazinessSolutionsEntities6 userProf = new LazinessSolutionsEntities6();
            var u = userProf.Jobs.Find(ID);
            LazinessSolutionsEntities4 userDeet = new LazinessSolutionsEntities4();
            var z = userDeet.AspNetUsers.Find(User.Identity.GetUserId());

            u.Getter        = User.Identity.GetUserName();
            u.Getter_Name   = User.Identity.GetUserId();
            u.Status        = "Assigned";
            u.Getter_Badges = z.Badge_Count;
            u.Getter_Phone  = z.Mobile_Phone;
            userProf.SaveChanges();

            string           AccountSid = "ACcd539f756b9224060b4e0568d0c614b3";
            string           AuthToken  = "d1dc9f49c5b32232aec0267fc582afcb";
            TwilioRestClient client;

            client = new TwilioRestClient(AccountSid, AuthToken);
            Message result = client.SendMessage(
                "+13132419747", "+1" + u.Getter_Phone, "Greetings, from Alfred! Your task '" + u.Title + "' has been picked up.");

            return(View("Details", u));
        }