public bool RemoveAnnouncement(string partitionKey, string rowKey)
        {
            if (!Init())
            {
                return(false);
            }

            // Create a retrieve operation that expects a connection entity.
            var retrieveOperation =
                TableOperation.Retrieve <AnnouncementModel>(partitionKey, rowKey);

            // Execute the operation.
            TableResult retrievedResult = _table.Execute(retrieveOperation);

            // Assign the result to a announcement entity.
            AnnouncementModel deleteEntity = (AnnouncementModel)retrievedResult.Result;

            // Create the Delete TableOperation.
            if (deleteEntity != null)
            {
                TableOperation deleteOperation = TableOperation.Delete(deleteEntity);

                // Execute the operation.
                _table.Execute(deleteOperation);
                return(true);
            }
            return(false);
        }
        public bool AddAnnouncement(AnnouncementModel announcement)
        {
            if (!Init())
            {
                return(false);
            }

            // Create the TableOperation object that inserts the announcement entity.
            var insertOperation = TableOperation.InsertOrReplace(announcement);

            // Execute the insert operation.
            _table.Execute(insertOperation);

            return(true);
        }
        public static void UpdateAnnouncent(AnnouncementViewModel announcement)
        {
            if (announcement == null)
            {
                return;
            }

            if (_repository == null)
            {
                _repository = new AnnoucementRepository();
            }


            // map view model to model
            var announcementToUpdate = new AnnouncementModel(announcement.PartitionKey, announcement.RowKey)
            {
                ExpirationDate   = announcement.ExpirationDate,
                Title            = announcement.Title,
                AnnouncementHtml = announcement.AnnouncementHtml
            };

            _repository.AddAnnouncement(announcementToUpdate);
        }
        public static void AddAnnouncent(AnnouncementViewModel newAnnouncement)
        {
            if (newAnnouncement == null)
            {
                return;
            }

            if (_repository == null)
            {
                _repository = new AnnoucementRepository();
            }


            // map view model to model
            var announcement = new AnnouncementModel(_partitionKey, Guid.NewGuid().ToString())
            {
                ExpirationDate   = newAnnouncement.ExpirationDate,
                Title            = newAnnouncement.Title,
                AnnouncementHtml = newAnnouncement.AnnouncementHtml
            };

            _repository.AddAnnouncement(announcement);
        }