private bool Pick3TenExist(DrawingResult drawing, int?parameter)
        {
            int result;
            var decenaFijo = Math.DivRem(drawing.Pick3, 100, out result);

            return(result == parameter);
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            DrawingResult drawingResult = _repository.GetEntity <DrawingResult>(id);

            _repository.DeleteEntity <DrawingResult>(drawingResult);
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public bool IsMemberDrawing(DrawingResult drawing, List <int> listNumber)
        {
            int parameter = 0;

            Math.DivRem(drawing.Pick3, 100, out parameter);
            return(listNumber.Contains(parameter));
        }
        public DrawingResult GetDrawingByDate(DateTime date, DrawType drawingType)
        {
            var           list    = _repository.GetList <DrawingResult>();
            DrawingResult drawing = list.Where(d => d.Date == date && d.Type == drawingType)
                                    .FirstOrDefault();

            return(drawing);
        }
 private int?GetValue(DrawingResult drawingResult)
 {
     if (drawingResult == null)
     {
         return(null);
     }
     return(drawingResult.Pick3);
 }
        private bool CorrTenExist(DrawingResult drawing, int?parameter)
        {
            int result;
            var decenaFijo = Math.DivRem(drawing.Pick3, 100, out result);

            return((result == parameter) ||
                   (drawing.Pick4First == parameter) ||
                   (drawing.Pick4Second == parameter));
        }
Exemple #7
0
 public ActionResult Edit(DrawingResult drawingResult)
 {
     if (ModelState.IsValid)
     {
         _repository.UpdateEntity <DrawingResult>(drawingResult);
         return(RedirectToAction("Index"));
     }
     return(View(drawingResult));
 }
Exemple #8
0
        // GET: DrawingResults/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DrawingResult drawingResult = _repository.GetEntity <DrawingResult>(id);

            if (drawingResult == null)
            {
                return(HttpNotFound());
            }
            return(View(drawingResult));
        }
        public void PrepareMessageTest()
        {
            Participant   test1 = new Participant("Test" + 1, "test" + 1 + "@email.com", "wishlist1", "test1");
            Participant   test2 = new Participant("Test" + 2, "test" + 2 + "@email.com", "test2");
            DrawingResult test  = new DrawingResult(test1, test2);

            DrawingResult.Seed = 123456789;

            Assert.AreEqual("[email protected],Test1,[email protected],wishlist1,Test2,[email protected],(Test2 has no wishlist),123456789", test.PrepareMessage("${SENDING_EMAIL},${GIVER_NAME},${GIVER_EMAIL},${GIVER_WISHLIST},${RECEIVER_NAME},${RECEIVER_EMAIL},${RECEIVER_WISHLIST},${SEED}", "*****@*****.**"), false);

            test = new DrawingResult(test2, test1);

            Assert.AreEqual("[email protected],Test2,[email protected],(Test2 has no wishlist),Test1,[email protected],wishlist1,123456789", test.PrepareMessage("${SENDING_EMAIL},${GIVER_NAME},${GIVER_EMAIL},${GIVER_WISHLIST},${RECEIVER_NAME},${RECEIVER_EMAIL},${RECEIVER_WISHLIST},${SEED}", "*****@*****.**"), false);
        }
        public void DrawingBelongToWeekResult()
        {
            DrawingResult drawing = new DrawingResult()
            {
                Date        = new DateTime(2019, 1, 8),
                Pick3       = 119,
                Pick4First  = 96,
                Pick4Second = 62,
                Type        = DrawType.Evening
            };

            var result = manager.IsDrawingBelongWeek(drawing, weekResult);

            Assert.IsTrue(result);
        }
        public void Delete(DrawingResult drawingResult)
        {
            var uow = _repository.UoW;

            try
            {
                uow.BeginTransaction();
                _repository.DeleteEntity(drawingResult);
                uow.CommitTransaction();
            }
            catch (Exception)
            {
                uow.RollbackTransaction();
            }
        }
        public DrawingResult Update(DrawingResult drawingResult)
        {
            var uow = _repository.UoW;

            try
            {
                uow.BeginTransaction();
                _repository.UpdateEntity(drawingResult);
                uow.CommitTransaction();
            }
            catch (Exception)
            {
                uow.RollbackTransaction();
                return(null);
            }
            return(drawingResult);
        }
        public bool IsDrawingBelongWeek(DrawingResult drawing, WeekResult weekResult)
        {
            if (drawing.Type != weekResult.DrawType)
            {
                return(false);
            }
            DateTime dateSunday   = weekResult.DateOfSunday;
            DateTime dateSaturday = dateSunday.AddDays(6);

            int d1 = dateSunday.CompareTo(drawing.Date);
            int d2 = dateSaturday.CompareTo(drawing.Date);

            if (d1 <= 0 && d2 >= 0)
            {
                return(true);
            }
            return(false);
        }
        public void DrawingNotBelongToWeekResult()
        {
            DrawingResult drawing = new DrawingResult()
            {
                Date        = new DateTime(2019, 1, 14),
                Pick3       = 762,
                Pick4First  = 13,
                Pick4Second = 61,
                Type        = DrawType.Evening
            };

            WeekResultManager manager = new WeekResultManager();
            DayOfWeek         a       = DateTime.Now.DayOfWeek;
            var s = Enum.GetNames(a.GetType());

            var result = manager.IsDrawingBelongWeek(drawing, weekResult);

            Assert.IsFalse(result);
        }
Exemple #15
0
        private int AmountDaysOfLastDrawing(DrawingResult drawing, List <DrawingResult> drawingListComplette)
        {
            var list = drawingListComplette.Where(d => d.Date < drawing.Date)
                       .ToList();
            int parameter;
            var drawingLast = new DrawingResult();

            Math.DivRem(drawing.Pick3, 100, out parameter);

            foreach (var item in list)
            {
                if (Pick3TenExist(item, parameter))
                {
                    drawingLast = item;
                    break;
                }
            }
            return((int)drawing.Date.Subtract(drawingLast.Date).TotalDays);
        }
Exemple #16
0
        public Delay GetAmountDayForPick3Tens(int pick3, DateTime dateTime, DrawType type)
        {
            var date        = dateTime.AddYears(-3);
            var drawingList = _repository.GetList <DrawingResult>(
                d => d.Date > date &&
                d.Date <= dateTime &&
                d.Type == type)
                              .OrderByDescending(d => d.Date)
                              .ToList();
            var drawingTest = new DrawingResult()
            {
                Type  = type,
                Date  = dateTime,
                Pick3 = pick3
            };

            return(new Delay()
            {
                DrawingResult = drawingTest,
                Days = AmountDaysOfLastDrawing(drawingTest, drawingList)
            });
        }
        public void PerfrormDrawingsTest()
        {
            for (int count = 12; count <= 100; count++)
            {
                List <Participant> inputs = new List <Participant>(count);

                for (int i = 0; i < count; i++)
                {
                    inputs.Add(new Participant("Test" + i, "test" + i + "@email.com", (i % (count / 3)).ToString()));
                }

                List <DrawingResult> results = DrawingResult.PerfrormDrawings(inputs);

                Assert.AreEqual(inputs.Count, results.Count, "Result size.");
                Assert.AreEqual(0, results.Where(x => x.Giver.Equals(x.Receiver)).Count(), "Self drawing.");
                Assert.AreEqual(inputs.Count, results.Select(x => x.Giver).Distinct().Count(), "All participants drew.");
                Assert.AreEqual(inputs.Count, results.Select(x => x.Receiver).Distinct().Count(), "All participants were drawn.");
                foreach (DrawingResult result in results)
                {
                    Assert.IsTrue(results.Where(x => x.Giver.Equals(result.Receiver) && x.Receiver.Equals(result.Giver)).Count() == 0, "Direct cycle.");
                }
                Assert.IsTrue(results.Where(result => result.Giver.Group.Length > 0 && result.Receiver.Group.Equals(result.Giver.Group)).Count() == 0, "Group exclusion.");
            }
        }