示例#1
0
        public void RabattBerechnungTestOk()
        {
            DetailsViewModel dView = Cmn.UContainer.Resolve <DetailsViewModel>(new ParameterOverrides()
            {
                { "bestPosRequired", false },
                { "currentRuleSet", InvVm.CurrentSelectedValidation }
            });

            dView.ArtikelNr    = "1001";
            dView.Bezeichnung  = "Mister Blister";
            dView.Menge        = new decimal(10.0005);
            dView.EinzelPreis  = new decimal(5.00);
            dView.VatItem      = PlugInSettings.Default.MwStDefaultValue;
            dView.Einheit      = "STK";
            dView.Rabatt       = 10;
            dView.BestellBezug = "22";
            dView.SaveCommand.Execute(null);
            Cmn.ListResults(dView.Results);
            Assert.IsTrue(dView.Results.IsValid);
            DetailsViewModels dModels = Cmn.UContainer.Resolve <DetailsViewModels>(new ParameterOverrides()
            {
                { "bestPosRequired", false },
                { "currentRuleSet", InvVm.CurrentSelectedValidation }
            });

            dModels.DetailsViewList.Add(dView);
            InvVm.DetailsView = dModels.DetailsViewList;
            InvVm.IsInvoiceValid();
            Cmn.ListResults(InvVm.Results);
            Assert.IsTrue(InvVm.Results.IsValid);
            InvVm.SaveEbinterfaceCommand.Execute(@"Daten\RabattSaved.xml");
        }
示例#2
0
 private void AddDetailsViewModelsToCollection()
 {
     DetailsViewModels.Add(new GameCardViewModel(new GameCardModel()));
     DetailsViewModels.Add(new CommunityDetailsViewModel());
     DetailsViewModels.Add(new IdleDetailsViewModel());
     DetailsViewModels.Add(new StreetBuyingViewModel());
     DetailsViewModels.Add(new StreetInteractionViewModel());
 }
        public ActionResult AddRate(DetailsViewModels model)
        {
            model.NewRate.UserId = User.Identity.GetUserId();
            //var errors = ModelState.Values.SelectMany(v => v.Errors);
            var bookTitle = db.Books.Where(p => p.BookId == model.NewRate.BookId).First().Title.Replace(" ", "-").ToLower().ToString();
            var book      = db.Books.Where(p => p.BookId == model.NewRate.BookId).Single();


            if (ModelState.IsValid)
            {
                db.Ratings.Add(model.NewRate);
                db.SaveChanges();

                book.AvgRating       = getRating(model.NewRate.BookId);
                db.Entry(book).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Details", "Book", new { id = model.NewRate.BookId, _title = bookTitle }));
        }
示例#4
0
        public async Task <IActionResult> Edit(DetailsViewModels model, IFormFile pic)
        {
            if (!this.ModelState.IsValid)
            {
                return(RedirectToAction("Index", "ErrorHandler"));
            }

            var bannerToUpdate = await this.bannerService.GetBannerByIdAsync(model.Id);

            var picturePath = OptimizeImage(pic, hostingEnv);

            if (picturePath != null)
            {
                var imagePath = Path.Combine(this.hostingEnv.WebRootPath, "images", bannerToUpdate.ImagePath.Remove(0, 9));
                System.IO.File.Delete(imagePath);
                var banner = await this.bannerService.UpdateBannerAsync(model.Id, picturePath, model.BannerLink, model.StartDate, model.EndDate);

                return(RedirectToAction("AllBanners", "Banner"));
            }
            var editedBanner = await this.bannerService.UpdateBannerAsync(model.Id, bannerToUpdate.ImagePath, model.BannerLink, model.StartDate, model.EndDate);

            return(RedirectToAction("AllBanners", "Banner"));
        }
示例#5
0
        public void SonderZeichenSaveTest()
        {
            DetailsViewModel dView = Cmn.UContainer.Resolve <DetailsViewModel>(new ParameterOverrides()
            {
                { "bestPosRequired", false },
                { "currentRuleSet", InvVm.CurrentSelectedValidation }
            });

            dView.ArtikelNr = "ertertasd&/<>";
            // ertertasd&amp;/&lt;&gt;
            DetailsViewModels dModels = Cmn.UContainer.Resolve <DetailsViewModels>(new ParameterOverrides()
            {
                { "bestPosRequired", false },
                { "currentRuleSet", InvVm.CurrentSelectedValidation }
            });

            dModels.DetailsViewList.Add(dView);
            InvVm.DetailsView  = dModels.DetailsViewList;
            InvVm.VmBillerName = Sozei;
            InvVm.SaveTemplateCommand.Execute(InvTemplateSonderzSave);
            XDocument xDoc = XDocument.Load(InvTemplateSonderzSave);
            var       xEl  = xDoc.Root.DescendantsAndSelf().First(p => p.Name.LocalName == "ArticleNumber");

            Assert.AreEqual("ertertasd&/<>", xEl.Value);
            XDocument xdoc  = XDocument.Load(InvTemplateSonderzSave);
            var       bName = xdoc.XPathSelectElement(BillerName, Nspc).Value;

            Assert.AreEqual(Sozei, bName);
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(InvTemplateSonderzSave);
            XmlNode root  = xmldoc.DocumentElement;
            XmlNode xName = root.SelectSingleNode(BillerName, Nspc);

            Assert.AreEqual(Sozei.EscapeXml(), xName.InnerXml);
        }
        public ActionResult Details(int id)
        {
            bool isAdmin = User.IsInRole("Admin");

            ViewBag.IsAdmin = isAdmin;
            ViewBag.isUser  = User.Identity.IsAuthenticated;
            var userId = User.Identity.GetUserId();
            var BookId = db.Books.Where(g => g.BookId == id);
            //var BookTitle = db.Books.Where(g => g.Title.Replace(" ", "-").ToLower() == title);
            var genres   = db.Genres.ToList();
            var books    = BookId.ToList();
            var comments = db.Comments.Include(p => p.User).Where(c => c.BookId == id && c.ParentId == 0).OrderByDescending(d => d.DateAdded).Take(20).ToList();

            ViewBag.countComments = db.Comments.Include(p => p.User).Where(c => c.BookId == id).Count();
            ViewBag.countReviews  = db.Reviews.Include(p => p.User).Where(c => c.BookId == id).Count();

            var userReview = db.Reviews.Include(p => p.User).Where(c => c.BookId == id && c.UserId == userId).SingleOrDefault();

            var reviews    = db.Reviews.Include(p => p.User).Include(p => p.Rate).Where(c => c.BookId == id).OrderByDescending(d => d.DateAdded).Take(5).ToList();
            var newComment = new Comment();

            newComment.BookId = id;
            var newRate = new Rate();

            newRate.BookId = id;
            ViewBag.Title  = BookId.Single().Title.ToString();

            double?rate = -1;

            try
            {
                rate = db.Ratings.Where(r => r.BookId == id).Average(a => a.Value);
            }
            catch
            {
                rate = -1;
            }


            var userRate = db.Ratings.Where(r => r.BookId == id && r.UserId == userId).ToList();

            ViewBag.user = userId;

            //var vm = new HomeViewModel()
            var vm = new DetailsViewModels()
            {
                NewComment   = newComment,
                Genres       = genres,
                SelectedBook = BookId,
                Comments     = comments,
                Ratings      = rate,
                UserRate     = userRate,
                Reviews      = reviews,
                NewRate      = newRate,
                userReview   = userReview

                               //SelectedBook = BookTitle
            };

            return(View(vm));
        }
示例#7
0
 // public DetailsViewModels DetailsView;
 public FrmDetailsList(DetailsViewModels viewModel)
 {
     InitializeComponent();
     ViewModel = viewModel;
     bindSrcDetailsList.DataSource = ViewModel;
 }