CoyoteMoves.Data_Access.RequestFormDB.StoreRequestFormInDatabaseAsPending C# (CSharp) Method

StoreRequestFormInDatabaseAsPending() public method

public StoreRequestFormInDatabaseAsPending ( RequestForm form ) : bool
form CoyoteMoves.Models.RequestItems.RequestForm
return bool
        public bool StoreRequestFormInDatabaseAsPending(RequestForm form)
        {
            SqlConnection connection = new SqlConnection(_connectionString);
            SqlCommand command = AddParametersForStoreRequestFormInDatabaseHelper(form);
            command.Connection = connection;
            command.Connection.Open();
            int result = command.ExecuteNonQuery();
            command.Connection.Close();

            return (result == 1);
        }

Usage Example

        // POST api/RequestForm/SendChangeRequest
        public HttpResponseMessage SendChangeRequest(JObject json)
        {
            int managerID = GetIDFromName((string)json["current"]["bazookaInfo"]["managerId"]);
            int f_managerID = GetIDFromName((string)json["future"]["bazookaInfo"]["managerId"]);

            HttpResponseMessage useForFailure = new HttpResponseMessage(HttpStatusCode.NotFound);
            if ((managerID == -1) && (f_managerID == -1))
            {
                useForFailure.Content = new StringContent("Both current and future managers were not found.");
                return useForFailure;
            }
            else if (managerID == -1)
            {
                useForFailure.Content = new StringContent("Current manager was not found.");
                return useForFailure;
            }
            else if (f_managerID == -1)
            {
                useForFailure.Content = new StringContent("Future manager was not found.");
                return useForFailure;
            }

            RequestForm obj = makeRequestForm(json);

            Collection<string> to = new Collection<string>();
            to.Add("*****@*****.**");
            EmailSender emailer = new EmailSender("Coyote Moves Request ", to, "*****@*****.**", "", HttpContext.Current.Server.MapPath("/CoyoteMoves/CoyoteMovesTemplate.pdf"));
            emailer.sendMovesRequest(obj);

            RequestFormDB formDB = new RequestFormDB();
            formDB.StoreRequestFormInDatabaseAsPending(obj);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }