示例#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"));
        }
示例#2
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));
        }
示例#3
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"));
        }