예제 #1
0
        /// <summary>
        ///
        ///  CREATOR: Steve Coonrod
        ///  CREATED: 2020/4/10
        ///  APPROVER: Matt Deaton
        ///
        ///  This is the click event to submit the form data to the database
        ///  It validates the form data, then creates a social media request object
        ///  to send through the manager to the accessor
        ///
        /// </summary>
        /// <remarks>
        ///
        /// UPDATER: NA
        /// UPDATED: NA
        /// UPDATE: NA
        ///
        /// </remarks>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            //The only validation happening on this form is that the strings
            //  from the text boxes are not empty
            //It is on the user creating the request to fill the fields out appropriately
            if (txtTitle.Text.Trim().Length > 0 && txtDescription.Text.Trim().Length > 0)
            {
                SocialMediaRequest newSocialMediaRequest = new SocialMediaRequest();
                newSocialMediaRequest.DateCreated      = DateTime.Now;
                newSocialMediaRequest.Open             = true;
                newSocialMediaRequest.RequestingUserID = _user.PUUserID;
                newSocialMediaRequest.RequestTypeID    = "Social Media";
                newSocialMediaRequest.Title            = txtTitle.Text;
                newSocialMediaRequest.Description      = txtDescription.Text;

                MessageBoxResult confirmation = MessageBox.Show("Title:\n" + newSocialMediaRequest.Title
                                                                + "\n\nDescription:\n" + newSocialMediaRequest.Description
                                                                + "\n\nSend this request?", "Send Request", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (confirmation.Equals(MessageBoxResult.Yes))
                {
                    sendRequest(newSocialMediaRequest);
                }
            }
            else if (txtTitle.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide a title for this post", "No Title", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (txtDescription.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide a description for this post", "No Description", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SocialMediaRequest socialMediaRequest = db.SocialMediaRequests.Find(id);

            db.SocialMediaRequests.Remove(socialMediaRequest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 /// <summary>
 ///
 /// Creator: Steve Coonrod
 /// Created: 2020/04/08
 /// Approver: Matt Deaton
 ///
 /// Manager method for adding a social media request
 ///
 /// </summary>
 /// <remarks>
 ///
 /// Updater: N/A
 /// Updated: N/A
 /// Update: N/A
 ///
 /// </remarks>
 /// <param name="request"></param>
 /// <returns></returns>
 public int AddSocialMediaRequest(SocialMediaRequest request)
 {
     try
     {
         return(_requestAccessor.InsertSocialMediaRequest(request));
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Request was unsuccessful.", ex);
     }
 }
예제 #4
0
 /// <summary>
 ///
 /// CREATOR: Steve Coonrod
 /// CREATED: 2020-04-10
 /// APPROVER: Matt Deaton
 ///
 /// This is a fake accessor method for inserting a social media request
 /// It returns a mock RequestID for the request if it passes the
 /// validation on the title and description values, otherwise it
 /// returns 0 for an unsuccessful insertion
 ///
 /// </summary>
 /// <remarks>
 ///
 /// UPDATER: NA
 /// UPDATED: NA
 /// UPDATE: NA
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public int InsertSocialMediaRequest(SocialMediaRequest request)
 {
     if (request.Title.Trim().Length > 0 && request.Description.Trim().Length > 0)
     {
         return(1000014);
     }
     else
     {
         return(0);
     }
 }
예제 #5
0
        public ActionResult GetGoogleContacts()
        {
            List <SocialMediaRequest> sm  = new List <SocialMediaRequest>();
            SocialMediaRequest        smr = new SocialMediaRequest()
            {
                FriendName = "ololade ahmed oyebanji", FriendsEmail = "*****@*****.**"
            };

            sm.Add(smr);
            ViewBag.EmailMessage = "   Hi there Damilola, this is lolade. I am driving from Okota to CMS tomorrow 21 January 2017. Let's share this trip together. Click on this link, pay 200 naira and meet me at the pick up LandMark, Church Roundabout. Destination LandMark is CMS. Join my trip network so we go together.";
            return(View("index", sm));
        }
예제 #6
0
 public ActionResult Edit([Bind(Include = "refid,SocialMedia,FriendName,FriendsEmail,dateAdded,dateModified,UserId,TripId")] SocialMediaRequest socialMediaRequest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(socialMediaRequest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", socialMediaRequest.UserId);
     ViewBag.TripId = new SelectList(db.Trips, "Id", "TripAdmin", socialMediaRequest.TripId);
     return(View(socialMediaRequest));
 }
예제 #7
0
        // GET: SocialMediaRequests/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SocialMediaRequest socialMediaRequest = db.SocialMediaRequests.Find(id);

            if (socialMediaRequest == null)
            {
                return(HttpNotFound());
            }
            return(View(socialMediaRequest));
        }
예제 #8
0
        // GET: SocialMediaRequests/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SocialMediaRequest socialMediaRequest = db.SocialMediaRequests.Find(id);

            if (socialMediaRequest == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", socialMediaRequest.UserId);
            ViewBag.TripId = new SelectList(db.Trips, "Id", "TripAdmin", socialMediaRequest.TripId);
            return(View(socialMediaRequest));
        }
예제 #9
0
        /// <summary>
        ///
        /// CREATOR: Steve Coonrod
        /// CREATED: 2020/4/10
        /// APPROVER: Matt Deaton
        ///
        /// This method adds a new Social Media Request to the DB
        ///
        /// </summary>
        /// <remarks>
        ///
        /// UPDATER: NA
        /// UPDATED: NA
        /// UPDATE: NA
        ///
        /// </remarks>
        /// <param name="request"></param>
        /// <returns></returns>
        public int InsertSocialMediaRequest(SocialMediaRequest request)
        {
            int requestID = 0;
            //Connection
            var conn = DBConnection.GetConnection();

            var cmd = new SqlCommand("sp_insert_social_media_request", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            //Parameters
            cmd.Parameters.Add("@DateCreated", SqlDbType.DateTime);
            cmd.Parameters.Add("@RequestTypeID", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@RequestingUserID", SqlDbType.Int);
            cmd.Parameters.Add("@Open", SqlDbType.Bit);
            cmd.Parameters.Add("@Title", SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@Description", SqlDbType.NVarChar, 500);
            cmd.Parameters.Add("@RequestID", SqlDbType.Int).Direction = ParameterDirection.Output;

            //Values
            cmd.Parameters["@DateCreated"].Value      = request.DateCreated;
            cmd.Parameters["@RequestTypeID"].Value    = request.RequestTypeID;
            cmd.Parameters["@RequestingUserID"].Value = request.RequestingUserID;
            cmd.Parameters["@Open"].Value             = request.Open;
            cmd.Parameters["@Title"].Value            = request.Title;
            cmd.Parameters["@Description"].Value      = request.Description;

            try
            {
                conn.Open();
                cmd.ExecuteScalar();
                requestID = (int)cmd.Parameters["@RequestID"].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(requestID);
        }
예제 #10
0
        public void TestCannotAddInvalidSocialMediaRequest()
        {
            //Arrange
            int requestID = 0;
            SocialMediaRequest request = new SocialMediaRequest
            {
                DateCreated      = DateTime.Now,
                Description      = "",//This will cause an unsucessful insertion
                Open             = true,
                RequestingUserID = 100000,
                RequestTypeID    = "Social Media",
                Title            = "A Good Title"
            };

            //Act
            requestID = _fakeRequestAccessor.InsertSocialMediaRequest(request);

            //Assert
            Assert.AreEqual(requestID, 0);
        }
예제 #11
0
        public void TestCanAddValidSocialMediaRequest()
        {
            //Arrange
            int requestID = 0;
            SocialMediaRequest request = new SocialMediaRequest
            {
                DateCreated      = DateTime.Now,
                Description      = "A Good Description",
                Open             = true,
                RequestingUserID = 100000,
                RequestTypeID    = "Social Media",
                Title            = "A Good Title"
            };

            //Act
            requestID = _fakeRequestAccessor.InsertSocialMediaRequest(request);

            //Assert
            Assert.AreNotEqual(requestID, 0);
        }
예제 #12
0
        /// <summary>
        ///
        /// CREATOR: Steve Coonrod
        /// CREATED: 2020/4/10
        /// APPROVER: Matt Deaton
        ///
        /// This method is where the call to the request manager is made.
        ///     it is called after the user confirms that they want to send the request
        ///
        /// </summary>
        /// <remarks>
        ///
        /// UPDATER: NA
        /// UPDATED: NA
        /// UPDATE: NA
        ///
        /// </remarks>
        ///
        /// </summary>
        /// <param name="request"></param>
        private void sendRequest(SocialMediaRequest request)
        {
            try
            {
                request.RequestID = _requestManager.AddSocialMediaRequest(request);

                if (request.RequestID != 0)
                {
                    txtDescription.Text = "";
                    txtTitle.Text       = "";

                    MessageBox.Show("The request was sent successfully", "Request Sent", MessageBoxButton.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem with the request.\n" + ex.Message,
                                "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }