예제 #1
0
        public void checkInputFromFakeData()
        {
            int score  = 0;
            int level  = 0;
            var result = _scoreService.Add(_FakeData, score, level);

            // check the whether the reuslt is 9
            Assert.AreEqual(9, result);
        }
예제 #2
0
 public ActionResult Add(Score Score)
 {
     if (ScoreService.Add(Score))
     {
         return(Redirect("Score"));
     }
     else
     {
         return(Content("no"));
     }
 }
        public JsonResult AddScore(Score score)
        {
            score.CreateDate = DateTime.Now;

            _scoreService.Add(score);
            _scoreService.Save();
            return(Json(new
            {
                Status = true
            }));
        }
예제 #4
0
 public ActionResult Create(ScoreViewModel score)
 {
     if (!ModelState.IsValid)
     {
         ErrorNotification("Kayıt Eklenemedi!");
         return(RedirectToAction("Create"));
     }
     _scoreService.Add(new Score
     {
         //TODO:Alanlar buraya yazılacak
         //Örn:BrandName = brand.BrandName,
     });
     SuccessNotification("Kayıt Eklendi.");
     return(RedirectToAction("ScoreIndex"));
 }
예제 #5
0
        public IHttpActionResult Score([FromBody] InputDTO inputDTO)
        {
            int score = 0;
            int level = 0;
            int res   = _scoreService.Add(inputDTO.input, score, level);

            if (res != -1)
            {
                return(Ok(res));
            }
            else
            {
                return(BadRequest("invalid input"));
            }
        }
예제 #6
0
 public ActionResult Create(ScoreViewModel score)
 {
     if (!ModelState.IsValid)
     {
         ErrorNotification("Kayıt Eklenemedi!");
         return(RedirectToAction("Create"));
     }
     _scoreService.Add(new Score
     {
         UserId     = score.UserId,
         ScoreDate  = DateTime.Now,
         ScoreTotal = score.ScoreTotal,
         ScoreType  = ScoreType.YoneticiPuanArtır
     });
     SuccessNotification("Kayıt Eklendi.");
     return(RedirectToAction("ScoreIndex"));
 }
        public ActionResult Question(FormCollection form, int questionid)
        {
            var formId   = _queryableRepository.Table.FirstOrDefault(x => x.KnowledgeTestId == questionid);
            var keys     = Request.Form.AllKeys;
            var reqForm  = form["item.Question"];
            var date     = DateTime.Now.ToShortDateString();
            var quiz     = _knowledgeTestService.GetAll().Where(x => (Convert.ToDateTime(x.KnowledgeDate.ToShortDateString()) == Convert.ToDateTime(date)));
            var quizList = quiz.ToList();

            if (reqForm == formId.ValidAnswerType)
            {
                _answerService.Add(new Answer
                {
                    UserId          = Convert.ToInt32(GeneralHelpers.GetUserId()),
                    KnowledgeTestId = questionid,
                    AnswerDate      = DateTime.Now,
                    ValidAnswer     = true
                });
                _scoreService.Add(new Score
                {
                    UserId     = Convert.ToInt32(GeneralHelpers.GetUserId()),
                    ScoreTotal = formId.Point,
                    ScoreType  = ScoreType.BilgiModulu,
                });
                SuccessNotification("Tebrikler! Cevabınız Doğru.");
            }
            else
            {
                _answerService.Add(new Answer
                {
                    UserId          = Convert.ToInt32(GeneralHelpers.GetUserId()),
                    KnowledgeTestId = questionid,
                    AnswerDate      = DateTime.Now,
                    ValidAnswer     = false
                });
                ErrorNotification("Üzgünüm Doğru Cevap " + formId.ValidAnswerType + " Olmalıydı :(");
            }

            return(RedirectToAction("Question"));
        }
예제 #8
0
        public ActionResult Edit(ApproveSaleViewModel sale)
        {
            var saleDefault = _queryableRepository.Table.Include("Product").Include("Customer").Include("User").FirstOrDefault(x => x.SaleId == sale.SaleId);

            if (!ModelState.IsValid)
            {
                ErrorNotification("Bir Hata Oluştu");
                return(RedirectToAction("DeleteEdit"));
            }
            var saleImage = _saleService.GetById(sale.SaleId);
            var userMail  = _userQueryableRepository.Table.AsNoTracking().FirstOrDefault(x => x.UserId == sale.UserId);

            try
            {
                if (sale.IsApproved == false)
                {
                    ErrorNotification("Satışı Onaylamadınız! Başka Bir İşlem Yapmak İster misiniz?");
                    return(Redirect(Request.UrlReferrer.ToString()));
                }
                // TODO: Add update logic here
                if (saleImage.InvoiceImage != null)
                {
                    _saleService.Update(new Sale
                    {
                        UserId          = sale.UserId,
                        InvoiceImage    = saleImage.InvoiceImage,
                        InvoiceDate     = sale.InvoiceDate,
                        AddDate         = saleImage.AddDate,
                        AmountOfSales   = sale.AmountOfSales,
                        InvoiceImageExt = ".png",
                        InvoiceNo       = sale.InvoiceNo,
                        ProductId       = sale.ProductId,
                        CustomerId      = sale.CustomerId,
                        SaleId          = sale.SaleId,
                        IsApproved      = sale.IsApproved,
                        ApprovedDate    = DateTime.Now,
                        InvoiceTotal    = sale.InvoiceTotal
                    });
                    _scoreService.Add(new Score
                    {
                        ScoreTotal = sale.AmountOfSales * saleDefault.Product.Point,
                        ScoreType  = ScoreType.UrunModulu,
                        UserId     = sale.UserId,
                        ScoreDate  = DateTime.Now
                    });
                    var mailEnable = System.Configuration.ConfigurationManager.AppSettings["MailEnable"];
                    if (mailEnable == "true")
                    {
                        var mail = MailHelper.SendMail(
                            $"Tebrikler {sale.InvoiceNo} Fatura Numaralı Satışınız Onaylandı.<br/> Lütfen bayipuan.com üzerinde takip ediniz.",
                            $"{userMail.Email}", "Satış Onaylanmadı!", true);
                        if (mail)
                        {
                            SuccessNotification("Mail Gönderildi");
                        }
                        else
                        {
                            ErrorNotification("Mail Gönderilemedi!");
                        }
                    }
                    SuccessNotification("Satış Onaylandı :)");
                    return(RedirectToAction("SaleIndex"));
                }
                _saleService.Update(new Sale
                {
                    UserId          = sale.UserId,
                    InvoiceImage    = sale.InvoiceImage,
                    InvoiceDate     = sale.InvoiceDate,
                    AddDate         = saleImage.AddDate,
                    AmountOfSales   = sale.AmountOfSales,
                    InvoiceImageExt = ".png",
                    InvoiceNo       = sale.InvoiceNo,
                    ProductId       = sale.ProductId,
                    CustomerId      = sale.CustomerId,
                    SaleId          = sale.SaleId,
                    IsApproved      = sale.IsApproved,
                    ApprovedDate    = DateTime.Now,
                    InvoiceTotal    = sale.InvoiceTotal
                });
                _scoreService.Add(new Score
                {
                    ScoreTotal = sale.AmountOfSales * saleDefault.Product.Point,
                    ScoreType  = ScoreType.UrunModulu,
                    UserId     = sale.UserId,
                    ScoreDate  = DateTime.Now
                });
                var mailEnablex = System.Configuration.ConfigurationManager.AppSettings["MailEnable"];
                if (mailEnablex == "true")
                {
                    var onayMail =
                        MailHelper.SendMail(
                            $"Tebrikler {sale.InvoiceNo} Fatura Numaralı Satışınız Onaylandı.<br/> Lütfen bayipuan.com üzerinde takip ediniz.",
                            $"{userMail.Email}", "Satış Onaylanmadı!", true);
                    if (onayMail)
                    {
                        SuccessNotification("Mail Gönderildi");
                    }
                    else
                    {
                        ErrorNotification("Mail Gönderilemedi!");
                    }
                }

                SuccessNotification("Satış Onaylandı :)");
                return(RedirectToAction("SaleIndex"));
            }
            catch
            {
                return(View());
            }
        }