예제 #1
0
        public async Task <IActionResult> ListSubscribers(string passcode)
        {
            var result = new List <Subscriber>();

            try
            {
                if (passcode == "simurghi")
                {
                    _log.LogEntrance(nameof(ListSubscribers), passcode.ToString());

                    var repository = new SubscriberRepository(_log, false);

                    result = repository.GetAll().ToList();

                    return(Ok(result));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                _log.LogError($"my exception : [{ex.Message}]  [{ex.StackTrace}]");

                return(NotFound(false));
            }
            finally
            {
                _log.LogExit(nameof(Add), result.ToString());
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var repo = new SubscriberRepository();

            gridSubscribers.DataSource = repo.GetAll();
            gridSubscribers.DataBind();
        }
예제 #3
0
        public async void SubscriberRepositoryTest()
        {
            var repo = new SubscriberRepository(_logger, false);

            var firstSubscriber = new Subscriber("Amir", "*****@*****.**");
            await repo.AddAsync(firstSubscriber);

            var id = firstSubscriber.Id;

            repo.Detach(firstSubscriber);

            var secondSubscriber = new Subscriber("Amir", "*****@*****.**");

            await Assert.ThrowsAsync <Microsoft.EntityFrameworkCore.DbUpdateException>(
                () => repo.AddAsync(secondSubscriber)
                );

            Assert.Throws <Microsoft.EntityFrameworkCore.DbUpdateException>(
                () => {
                repo.Add(secondSubscriber);
            });

            //we should reconnect to see the deleted objects
            repo = new SubscriberRepository(_logger, false);

            repo.Delete(id);

            var count = repo.GetAll().Count();

            Assert.Equal(0, count);
        }
예제 #4
0
        protected void btnSendToSubscribers_Click(object sender, EventArgs e)
        {
            if (RadEditor1.Content == string.Empty)
            {
                ((AdminPanel)Master).GeneralMessage = "متن مطلب خالی است";
                ((AdminPanel)Master).MessageType    = MessageType.Error;
                return;
            }

            SubscriberRepository repo        = new SubscriberRepository();
            IList <Subscriber>   subscribers = repo.GetAll();

            foreach (Subscriber subscriber in subscribers)
            {
                Utility.SendEmail("*****@*****.**", subscriber.EMail, RadEditor1.Text, "تیارا الکتریک",
                                  "atc@8873");
            }
        }
        public void Count_ShouldReturnZero()
        {
            var count = subscriberRepository.GetAll().Count;

            Assert.Equal(0, count);
        }
예제 #6
0
        public JsonResult GetList()
        {
            var result = SubscriberRepository.GetAll();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }