public void Add_Should_Insert_Key_Data_And_ExpiryDate()
        {
            //Arrange
            var testKey   = "test";
            var testValue = "data";

            //Act
            _instance.Add(testKey, testValue, TimeSpan.FromDays(30));

            //Assert
            Assert.IsTrue(_instance.Exists(testKey));
        }
        public void AddItemToStoreExistingKey()
        {
            //Arrange
            string key = "key2";

            _dataStore.Add(key, "5");


            //Act
            _sut.Add(key, "6"); //try adding when the key already exists

            //Assert
            Assert.AreEqual(_dataStore.Get(key), "6");
        }
        public async Task <HttpResponseMessage> Post([FromBody] JObject formData)
        {
            if (null == formData)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            try {
                HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.OK);
                Response.Content =
                    new StringContent(
                        JsonConvert.SerializeObject(
                            await _DataStore.Add(
                                JsonConvert.DeserializeObject <IArticle>(
                                    formData.ToString()
                                    )
                                )
                            )
                        );

                return(Response);
            } catch {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Exemple #4
0
        /// <summary>
        /// This method is invoked every time the TfsWarehouse OLAP cube is
        /// synchronized and before MakeDataChanges. This method adds
        /// "My Fact" to the cube.
        /// </summary>
        /// <returns>SchemaChangesResult</returns>
        public SchemaChangesResult MakeSchemaChanges()
        {
            var config = m_dataStore.GetWarehouseConfig();
            var fact   = config.GetFact("My Fact");

            if (fact == null)
            {
                /// Add a fact to TfsWarehouse OLAP cube if it doesn't exist.
                fact = CreateFact();
                m_dataStore.BeginTransaction();

                try
                {
                    config.Facts.Add(fact);
                    m_dataStore.Add(config);

                    m_dataStore.CommitTransaction();
                    return(SchemaChangesResult.ChangesComplete);
                }
                catch
                {
                    m_dataStore.RollbackTransaction();
                    throw;
                }
            }
            else
            {
                return(SchemaChangesResult.NoChanges);
            }
        }
Exemple #5
0
        public void SaveEvents(Guid aggregateId, IEnumerable <Event> events, int expectedVersion)
        {
            var myDump = new List <EventDescriptor>();

            var currentVersion = _db.TryLoadData().Any(e => e.Id == aggregateId) ?
                                 _db.TryLoadData().Where(e => e.Id == aggregateId).Max(e => e.Version)
             : 0;

            if (currentVersion != 0 && expectedVersion == -1)
            {
                throw new Concurrency();
            }

            if (currentVersion != expectedVersion && expectedVersion != -1)
            {
                throw new Concurrency();
            }

            var i = expectedVersion;

            foreach (var @event in events)
            {
                i++;
                @event.Version = i;
                myDump.Add(new EventDescriptor(aggregateId, _serializer.Serialize(@event), i));
            }

            _db.Add(myDump);
        }
        /// <summary>
        /// Sets the <see cref="IBusinessObjectProvider"/> to be associated with the <see cref="BusinessObjectProviderAttribute"/> type specified.
        /// </summary>
        /// <param name="businessObjectProviderAttributeType">
        /// A <see cref="Type"/> derived from <see cref="BusinessObjectProviderAttribute"/>. Must not be <see langword="null" />.
        /// </param>
        /// <param name="provider">
        /// The <see cref="IBusinessObjectProvider"/> instance to be associated with the <paramref name="businessObjectProviderAttributeType"/>.
        /// Pass <see langword="null"/> to remove the association.
        /// </param>
        public static void SetProvider(Type businessObjectProviderAttributeType, IBusinessObjectProvider provider)
        {
            ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom(
                "businessObjectProviderAttributeType", businessObjectProviderAttributeType, typeof(BusinessObjectProviderAttribute));

            if (provider != null)
            {
                BusinessObjectProviderAttribute attribute = CreateBusinessObjectProviderAttribute(businessObjectProviderAttributeType);
                if (!TypeExtensions.CanAscribeTo(provider.GetType(), attribute.BusinessObjectProviderType))
                {
                    throw new ArgumentException(
                              "The provider is not compatible with the provider-type required by the businessObjectProviderAttributeType's instantiation.", "provider");
                }

                if (provider is BusinessObjectProvider)
                {
                    ((BusinessObjectProvider)provider)._providerAttribute = attribute;
                }
            }

            s_businessObjectProviderStore.Remove(businessObjectProviderAttributeType);
            if (provider != null)
            {
                s_businessObjectProviderStore.Add(businessObjectProviderAttributeType, provider);
            }
        }
Exemple #7
0
        public StorageWriter(int receiverId, string host, int port, int firstDbNum, int periodInMs, int trimLength,
                             EventHandler <IError> dlgtOnError, string keySuffix,
                             Func <string, T, KeyContext, bool> dlgtFilter = null)
        {
            this.keySuffix = keySuffix;

            // Init DataStore
            dataStore = DataStore.Create <T>(host, database: firstDbNum, isDurationMeasured: true, port: port);

            periodicProcessing = new PeriodicProcessing(
                // PeriodicProc
                () =>
            {
                KeyValuePair <string, T> pair;
                while (cqueData.TryDequeue(out pair))
                {
                    try
                    {
                        if (dlgtFilter?.Invoke(pair.Key, pair.Value, GetKeyContext(pair.Key)) != false)
                        {
                            dataStore.Add(pair.Key, pair.Value, trimLength);

                            // Publish DataStore "INSERTED" event
                            dataStore.PublishAsync("ReceiverChannel", $"INSERTED|DATA_RECEIVER|{receiverId}");
                        }
                    }
                    catch (Exception e)
                    {
                        LogToScreen.Exception(e);
                    }
                }
            },
                e => dlgtOnError(this, new Error(e)),
                periodInMs);
        }
Exemple #8
0
        public async Task <HttpResponseMessage> Post([ModelBinder(typeof(JsonUserBinder))] IUser NewUser)
        {
            if (null == NewUser)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            ScryptEncoder Hasher         = new ScryptEncoder();
            IUser         ExistingRecord = await _DataStore.Get(NewUser.Id);

            // Register new profile
            if (null == ExistingRecord)
            {
                await _DataStore.Add(NewUser.UpdatePasswordHash(Hasher.Encode(string.Format("{0}:{1}", NewUser.EmailAddress, NewUser.PasswordHash))));

                Email NewMail = new Email(NewUser.EmailAddress, NewUser.DisplayName);
                NewMail.Subject = "New Account Created";
                NewMail.Body    =
                    @"This email is to confirm the creation of your account on the DevSpace website.

If you did not create this account, please contact [email protected].";
                NewMail.Send();

                return(new HttpResponseMessage(HttpStatusCode.Created));
            }

            // You can only post a new profile if you're not authenticated
            if (!Thread.CurrentPrincipal?.Identity?.IsAuthenticated ?? true)
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }

            // You can only update yourself
            if (!(Thread.CurrentPrincipal.Identity as DevSpaceIdentity).Identity.Id.Equals(NewUser.Id))
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }

            if (!string.IsNullOrWhiteSpace(NewUser.PasswordHash))
            {
                NewUser = NewUser.UpdatePasswordHash(Hasher.Encode(string.Format("{0}:{1}", NewUser.EmailAddress, NewUser.PasswordHash)));
            }

            await _DataStore.Update(NewUser);

            Email UpdateMail = new Email(NewUser.EmailAddress, NewUser.DisplayName);

            UpdateMail.Subject = "Account Updated";
            UpdateMail.Body    =
                @"This email is to confirm your account on the DevSpace website was updated.

If you did not update this account, please contact [email protected].";
            UpdateMail.Send();

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public IActionResult Post([FromBody] Value value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _dataStore.Add(value);
            return(CreatedAtAction("Get", new { id = value.Id }, value));
        }
Exemple #10
0
        /// <summary>
        /// Adds a new element to the store.
        /// </summary>
        /// <param name="key">The key of the new element.</param>
        /// <param name="value">The value of the new element.</param>
        /// <exception cref="ArgumentNullException"><paramref name="key"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">An item with an equal key already exists in the store.</exception>
        public void Add(TKey key, TValue value)
        {
            ArgumentUtility.DebugCheckNotNull("key", key);
            // value can be null

            lock (_lock)
            {
                _innerStore.Add(key, value);
            }
        }
Exemple #11
0
        public async Task <bool> Handle(ActivateRequestedMessage receivedEvent)
        {
            var eventName = receivedEvent.GetType().Name;

            logger.LogInformation("Received event [{eventName}] with MobileOrderId {mobileOrderId} ActivationCode {activationCode}", eventName, receivedEvent.MobileOrderId, receivedEvent.ActivationCode);

            try
            {
                using (var tx = dataStore.BeginTransaction())
                {
                    dataStore.Add(new Order
                    {
                        MobileId       = receivedEvent.MobileId,
                        PhoneNumber    = receivedEvent.PhoneNumber,
                        ActivationCode = receivedEvent.ActivationCode,
                        MobileOrderId  = receivedEvent.MobileOrderId,
                        Status         = OrderStatus.New,
                        Type           = OrderType.Activate,
                    });
                }

                using (var tx = dataStore.BeginTransaction())
                {
                    var result = await externalMobileTelecomsNetworkService.PostOrder(new ExternalMobileTelecomsNetworkOrder
                    {
                        PhoneNumber    = receivedEvent.PhoneNumber,
                        Reference      = receivedEvent.MobileOrderId,
                        ActivationCode = receivedEvent.ActivationCode
                    });

                    if (!result)
                    {
                        tx.Rollback();
                        monitoring.ActivateOrderFailed();
                        return(false);
                    }

                    dataStore.Sent(receivedEvent.MobileOrderId);
                    Publish(receivedEvent.MobileOrderId);
                    monitoring.ActivateOrderSent();
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error while processing event {eventName} - MobileOrderId={mobileOrderId}", eventName, receivedEvent.MobileOrderId);
                return(false);
            }

            return(true);
        }
Exemple #12
0
        public void Initialize(IDataStore dataStore)
        {
            if (dataStore.GetAll <UrlCheckTask>().Any())
            {
                return;
            }

            using (var transaction = dataStore.BeginTransaction())
            {
                foreach (var x in GetTasksFromMemory())
                {
                    dataStore.Add(x);
                }

                dataStore.SaveChanges();
                transaction.Commit();
            }
        }
Exemple #13
0
        public IActionResult Create([FromBody] OrderToAdd orderToAdd)
        {
            var order = new Order
            {
                PhoneNumber    = orderToAdd.PhoneNumber,
                Reference      = orderToAdd.Reference,
                Type           = OrderTypes.Activate.ToString(),
                Status         = "New",
                ActivationCode = orderToAdd.ActivationCode
            };

            using (dataStore.BeginTransaction())
            {
                dataStore.Add(order);
            }

            return(new OkResult());
        }
Exemple #14
0
        protected virtual void DataStore_Add_Item_Adds_Item()
        {
            // Arrange
            FooModel item = _dataStore.Create();

            item.AutoPopulate();

            // Act
            _dataStore.Add(item);
            _dataStore.SaveChanges();
            var result = GetItemById(item.ID);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(item.ID, result.ID);
            Assert.AreEqual(item.Title, result.Title);
            Assert.AreEqual(item.CreateDate.ToString(),
                            result.CreateDate.Kind == DateTimeKind.Utc
                    ? result.CreateDate.ToLocalTime().ToString()
                    : result.CreateDate.ToString());
            Assert.AreEqual(item.Content, result.Content);
            if (_dataStore.SupportsComplexStructures)
            {
                Assert.IsNotNull(result.Comments);
                Assert.AreEqual(item.Comments.Count, result.Comments.Count);
                try
                {
                    Assert.AreEqual(item.Comments.OrderBy(c => c.ID).FirstOrDefault(), result.Comments.OrderBy(c => c.ID).FirstOrDefault());
                }
                catch
                {
                    Assert.AreEqual(item.Comments.OrderBy(c => c.ID).FirstOrDefault().ID, result.Comments.OrderBy(c => c.ID).FirstOrDefault().ID);
                    Assert.AreEqual(item.Comments.OrderBy(c => c.ID).FirstOrDefault().Author, result.Comments.OrderBy(c => c.ID).FirstOrDefault().Author);
                    Assert.AreEqual(item.Comments.OrderBy(c => c.ID).FirstOrDefault().Message, result.Comments.OrderBy(c => c.ID).FirstOrDefault().Message);
                }
            }

            // cleanup
            CleanOutItemFromStore(item);
        }
Exemple #15
0
        public void Run()
        {
            var fromDate = GetLastRunDate();

            if (fromDate.Date != DateTime.Now.Date)
            {
                fromDate = DateTime.Today;
            }

            Console.WriteLine($"[{DateTime.Now}] {nameof(BlockService)} - Starting from {fromDate}");

            var badIps  = logFileDataSource.GetBadIps(fromDate);
            var runtime = badIps.LastOrDefault()?.Time.AddSeconds(1) ?? DateTime.Now;

            foreach (var ipEntry in badIps)
            {
                var isBlocked = dataStore.IsIPBlocked(ipEntry.IP, logFileDataSource.GetName(), ipEntry.Ports, ipEntry.Protocol.ToString());

                if (!isBlocked)
                {
                    var blockEntry = new BlockedEntry(ipEntry, logFileDataSource.GetName());
                    blockEntry.IpLocation = ipLocator.GetIpLocation(blockEntry.Ip);

                    var policy = policyFactory.GetPolicy(blockEntry);

                    if (policy.ShouldBlock() && ipBlocker.Block(blockEntry, policy, out var ruleName))
                    {
                        blockEntry.RuleName  = ruleName;
                        blockEntry.IsBLocked = true;
                        dataStore.Add(blockEntry, policy, logFileDataSource.GetName());
                    }
                }
            }

            dataStore.SaveConfigValue("LastRunDate", runtime.ToString());

            Console.WriteLine($"[{DateTime.Now}] {nameof(BlockService)} - Complete");
        }
        public bool AddUser(UserDataInDb user, string passWord)
        {
            try
            {
                user.Id       = Guid.NewGuid().ToString();
                user.IsActive = false;

                var hashAndSalt = HashHelper.GenerateSaltedSHA1(passWord);

                user.HashedAndSaltedPassword = hashAndSalt.hashedAndSalted;
                user.SaltString = hashAndSalt.salt;

                dataStore.Add(user);

                log.Info("New user Added: {@user}", user.ToString());
                return(true);
            }
            catch (Exception ex)
            {
                Debugger.Break();
                return(false);
            }
        }
 public async Task <HttpResponseMessage> Post([ModelBinder(typeof(JsonTagBinder))] ITag newTag)
 {
     try {
         if (-1 == newTag.Id)
         {
             HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.Created);
             Response.Content = new StringContent(await Task.Factory.StartNew(() => JsonConvert.SerializeObject(_DataStore.Add(newTag).Result, Formatting.None)));
             return(Response);
         }
         else
         {
             HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.NoContent);
             Response.Content = new StringContent(await Task.Factory.StartNew(() => JsonConvert.SerializeObject(_DataStore.Update(newTag).Result, Formatting.None)));
             return(Response);
         }
     } catch {
         return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
     }
 }
Exemple #18
0
        public async Task <HttpResponseMessage> Post([ModelBinder(typeof(JsonStudentCodeBinder))] IStudentCode value)
        {
            MutableStudentCode NewStudentCode = new MutableStudentCode {
                Email = value.Email
            };

            if (null == NewStudentCode)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            // Check for .edu email
            if (string.IsNullOrWhiteSpace(NewStudentCode.Email))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            if (!NewStudentCode.Email.Trim().EndsWith(".edu", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            // Check DataStore for existing code
            IList <IStudentCode> ExistingCodes = await _DataStore.Get("Email", NewStudentCode.Email);

            //	If exists, resent existing code
            if (ExistingCodes.Count > 0)
            {
                SendEmail(ExistingCodes[0]);
                return(new HttpResponseMessage(HttpStatusCode.NoContent));
            }

            // Generate Code
            NewStudentCode.Code = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "").Substring(0, 16);
            while (1 == (await _DataStore.Get("Code", NewStudentCode.Code)).Count)
            {
                NewStudentCode.Code = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "").Substring(0, 16);
            }

            Newtonsoft.Json.Linq.JObject input = new Newtonsoft.Json.Linq.JObject {
                ["discount"] = new Newtonsoft.Json.Linq.JObject {
                    ["type"]               = "access",
                    ["code"]               = NewStudentCode.Code,
                    ["event_id"]           = EventBriteEventId,
                    ["ticket_class_ids"]   = new Newtonsoft.Json.Linq.JArray(new[] { EventBriteTicketId }),
                    ["quantity_available"] = 1
                }
            };

            try {
                HttpResponseMessage EventBriteResponse = await EventBriteApi.PostAsync(
                    string.Empty,
                    new StringContent(
                        input.ToString(),
                        Encoding.UTF8,
                        "application/json"
                        )
                    );

                EventBriteResponse.Dispose();
            } catch (WebException) {
                return(new HttpResponseMessage(HttpStatusCode.BadGateway));
            } catch (Exception) {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            // Store Code in DataStore
            NewStudentCode.Id = (await _DataStore.Add(NewStudentCode)).Id;

            // Email Code
            SendEmail(NewStudentCode);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Exemple #19
0
 private void AddNewEntry(LogEntry entry)
 {
     entry.Timestamp = DateTime.Now;
     entry.Id        = _dataStore.Count;
     _dataStore.Add(entry);
 }
Exemple #20
0
 /// <summary>
 /// Add to the specified data store
 /// </summary>
 /// <param name="key">The key of the request data</param>
 /// <param name="value">Base64 encoded data</param>
 public void Add(string key, string value)
 {
     _dataStore.Add(key, value);
 }
        public async Task <HttpResponseMessage> Post([ModelBinder(typeof(JsonSessionBinder))] ISession postedSession)
        {
            try {
                IUser CurrentUser = (Thread.CurrentPrincipal.Identity as DevSpaceIdentity)?.Identity;

                if (-1 == postedSession.Id)
                {
                    HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.Created);
                    Response.Content = new StringContent(await Task.Factory.StartNew(() => JsonConvert.SerializeObject(_DataStore.Add(postedSession).Result, Formatting.None)));

                    Email Mail = new Email(CurrentUser.EmailAddress, CurrentUser.DisplayName);
                    Mail.Subject = "Session Submitted: " + postedSession.Title;
                    Mail.Body    = string.Format(
                        @"This message is to confirm the submission of your session: {0}.

You may continue to make changes to your session until June 15th.

You should receive an email with the status of your submission on or around June 25th.",
                        postedSession.Title);
                    Mail.Send();

                    return(Response);
                }
                else
                {
                    HttpResponseMessage Response = new HttpResponseMessage(HttpStatusCode.NoContent);
                    Response.Content = new StringContent(await Task.Factory.StartNew(() => JsonConvert.SerializeObject(_DataStore.Update(postedSession).Result, Formatting.None)));

                    Email Mail = new Email(CurrentUser.EmailAddress, CurrentUser.DisplayName);
                    Mail.Subject = "Session Updated: " + postedSession.Title;
                    Mail.Body    = string.Format(
                        @"This message is to confirm the update of your session: {0}.

You may continue to make changes to your session until June 15th.

You should receive an email with the status of your submission on or around June 25th.",
                        postedSession.Title);
                    Mail.Send();

                    return(Response);
                }
            } catch {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Exemple #22
0
        public async Task <HttpResponseMessage> Post([ModelBinder(typeof(JsonStudentCodeBinder))] IStudentCode value)
        {
            MutableStudentCode NewStudentCode = new MutableStudentCode {
                Email = value.Email
            };

            if (null == NewStudentCode)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            // Check for .edu email
            if (string.IsNullOrWhiteSpace(NewStudentCode.Email))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            if (!NewStudentCode.Email.Trim().EndsWith(".edu", StringComparison.InvariantCultureIgnoreCase))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            // Check DataStore for existing code
            IList <IStudentCode> ExistingCodes = await _DataStore.Get("Email", NewStudentCode.Email);

            //	If exists, resent existing code
            if (ExistingCodes.Count > 0)
            {
                SendEmail(ExistingCodes[0]);
                return(new HttpResponseMessage(HttpStatusCode.NoContent));
            }

            // Generate Code
            NewStudentCode.Code = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "").Substring(0, 16);
            while (1 == (await _DataStore.Get("Code", NewStudentCode.Code)).Count)
            {
                NewStudentCode.Code = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "").Substring(0, 16);
            }

            // Call EventBrite to create code
#if DEBUG
            string EventBriteApiKey   = Environment.GetEnvironmentVariable("EVENTBRITEAPIKEY", EnvironmentVariableTarget.Machine);
            string EventBriteEventId  = Environment.GetEnvironmentVariable("EVENTBRITEEVENTID", EnvironmentVariableTarget.Machine);
            string EventBriteTicketId = Environment.GetEnvironmentVariable("EVENTBRITETICKETID", EnvironmentVariableTarget.Machine);
#else
            string EventBriteApiKey   = ConfigurationManager.AppSettings["EventBriteApiKey"];
            string EventBriteEventId  = ConfigurationManager.AppSettings["EventBriteEventId"];
            string EventBriteTicketId = ConfigurationManager.AppSettings["EventBriteTicketId"];
#endif
            EventBriteApiObject JsonObject = new EventBriteApiObject {
                access_code = new AccessCode {
                    code               = NewStudentCode.Code,
                    ticket_ids         = new string[] { EventBriteTicketId },
                    quantity_available = 1
                }
            };

            string Uri = string.Format("https://www.eventbriteapi.com/v3/events/{0}/access_codes/", EventBriteEventId);

            HttpWebRequest EventBriteRequest = HttpWebRequest.Create(Uri) as HttpWebRequest;
            EventBriteRequest.Headers.Add("Authorization", string.Format("Bearer {0}", EventBriteApiKey));
            EventBriteRequest.ContentType = "application/json";
            EventBriteRequest.Accept      = "application/json";
            EventBriteRequest.Method      = "POST";

            byte[] RequestBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(JsonObject, Formatting.None));
            EventBriteRequest.ContentLength = RequestBytes.Length;
            using (Stream RequestStream = EventBriteRequest.GetRequestStream())
                RequestStream.Write(RequestBytes, 0, RequestBytes.Length);

            try {
                using (HttpWebResponse EventBriteResponse = await EventBriteRequest.GetResponseAsync() as HttpWebResponse);
            } catch (WebException) {
                return(new HttpResponseMessage(HttpStatusCode.BadGateway));
            } catch (Exception) {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            // Store Code in DataStore
            NewStudentCode.Id = (await _DataStore.Add(NewStudentCode)).Id;

            // Email Code
            SendEmail(NewStudentCode);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
 public void AddNegativeWord(string word)
 {
     _dataStore.Add(word);
 }