コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            OpenJobModel openJobModel = db.OpenJobs.Find(id);

            db.OpenJobs.Remove(openJobModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "JobID,FirstName,LastName,Email,PhoneNumber,Date,Message,TechNotes,Estimate,FinalCost,WorkComplete,AssetModel,AssetType")] OpenJobModel openJobModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(openJobModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(openJobModel));
 }
コード例 #3
0
        public void ServiceRequestDetails()
        {
            // Arrange
            ServiceRequestController controller = new ServiceRequestController();

            OpenJobModel openJobModel = new OpenJobModel
            {
                FirstName    = "Albumius",
                LastName     = "Artistus",
                Email        = "*****@*****.**",
                PhoneNumber  = "715-555-5555",
                Date         = DateTime.Now,
                Message      = "hackle frackle",
                TechNotes    = "I am a technote",
                Estimate     = 10.00,
                FinalCost    = 10.00,
                WorkComplete = true,
                AssetModel   = "1337",
                AssetType    = "Laptop"
            };

            var fullName    = openJobModel.FirstName.ToString() + openJobModel.LastName.ToString();
            var email       = openJobModel.Email.ToString();
            var phoneNumber = openJobModel.PhoneNumber.ToString();
            var date        = openJobModel.Date.ToString();
            var message     = openJobModel.Message.ToString();


            var body = "Lead details: {0} // {1} // {2} // {3} // {4}";


            SmtpClient client = new SmtpClient();


            MailMessage mailMessage = new MailMessage();


            mailMessage.To.Add("*****@*****.**");


            mailMessage.Subject = "Service Request lead sent " + DateTime.Now.ToString();


            mailMessage.Body = string.Format(body, fullName, email, phoneNumber, date, message);


            client.Send(mailMessage);

            // Act
            ViewResult result = controller.ServiceRequestDetails(openJobModel) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #4
0
        // GET: TechnicianInterface/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OpenJobModel openJobModel = db.OpenJobs.Find(id);

            if (openJobModel == null)
            {
                return(HttpNotFound());
            }
            return(View(openJobModel));
        }
コード例 #5
0
        // Bind is used to only pass an object with only the parameters included below.
        public ActionResult ServiceRequestForm([Bind(Include = "JobID,FirstName,LastName,Email,PhoneNumber,Date,Message")] OpenJobModel openJobModel)
        {
            // If the instance variables are OK'd with the model, then continue.
            if (ModelState.IsValid)
            {
                // The controller adds the filled up model object to the database. TODO: REMOVE THIS
                // db.OpenJobs.Add(openJobModel);
                // db.SaveChanges();

                // Return to the ServiceRequestDetails page, and send in a filled up openJobModel object to the Redirect.
                return(RedirectToAction("ServiceRequestDetails", openJobModel));
            }

            return(View(openJobModel));
        }
コード例 #6
0
        // GET: JobsPosting/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            OpenJobModel jobModel = new OpenJobModel();

            jobModel.Job = js.Get_Posting_By_ID(id);
            jobModel.ApplicationQuestions = js.getQuestionsByJobID(jobModel.Job.Job_ID).ToList();
            //OpenJobs job = js.Get_Posting_By_ID(id);
            if (jobModel == null)
            {
                return(HttpNotFound());
            }
            return(View(jobModel));
        }
コード例 #7
0
        // GET: Service Request Details view
        public ActionResult ServiceRequestDetails(OpenJobModel openJobModel)
        {
            // If the openJobModel is empty, throw an exception.
            if (openJobModel == null)
            {
                throw new ArgumentNullException(nameof(openJobModel));
            }
            else
            {
                // Notes: https://stackoverflow.com/questions/26784366/how-to-send-email-from-mvc-5-application
                // Setting the object member variables to local variables
                var fullName    = openJobModel.FirstName.ToString() + openJobModel.LastName.ToString();
                var email       = openJobModel.Email.ToString();
                var phoneNumber = openJobModel.PhoneNumber.ToString();
                var date        = openJobModel.Date.ToString();
                var message     = openJobModel.Message.ToString();

                // String format for message body
                var body = "Lead details: {0} // {1} // {2} // {3} // {4}";

                // Creating a Smtp client object to send the email in
                SmtpClient client = new SmtpClient();

                // Create a new email to send through the client
                MailMessage mailMessage = new MailMessage();

                // Email to send the message to (hardcoded)
                mailMessage.To.Add("*****@*****.**");

                // Subject for the email message
                mailMessage.Subject = "Service Request lead sent " + DateTime.Now.ToString();

                // Body for the email message, containing the lead information
                mailMessage.Body = string.Format(body, fullName, email, phoneNumber, date, message);

                // Send the email
                client.Send(mailMessage);
            }



            // Return the view with the filled up openJobModel object.
            return(View(openJobModel));
        }