Ejemplo n.º 1
0
        public static string CreateSubmission(string firstName, string lastName,
                                              string emailAddress, Guid serialNumber)
        {
            if (!CheckSerialNumberExists(serialNumber))
            {
                return("That is not a valid Serial Number.");
            }
            else if (!CheckSerialNumberSubmissionCount(serialNumber))
            {
                return("This Serial Number has already been redeemed twice.");
            }

            SubmissionModel submissionData = new SubmissionModel
            {
                FirstName    = firstName,
                LastName     = lastName,
                EmailAddress = emailAddress,
                SerialNumber = serialNumber
            };

            string sqlQuery = @"INSERT INTO dbo.Submission (FirstName, LastName, EmailAddress, SerialNumber)
                                VALUES (@FirstName, @LastName, @EmailAddress, @SerialNumber);";

            int rowsInserted = DBDataAccess.SaveData <SubmissionModel>(sqlQuery, submissionData);

            return(rowsInserted == 1 ? "Submission Successful!" : "There seems to be a problem, try submitting again.");
        }