Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Company,Email,City,Postal,Street,Country,CreatorId,ModificationDate,CreationDate")] Customer customer)
 {
     Log.Debug("POST/Edit");
     if (ModelState.IsValid)
     {
         using (var uow = new UoW()){
             var customersRepo  = uow.GetRepository <ICustomerRepository>();
             var customermodify = customersRepo.GetByKey(customer.Id);
             customermodify.FirstName = customer.LastName;
             customermodify.LastName  = customer.LastName;
             customermodify.Company   = customer.Company;
             customermodify.Email     = customer.Email;
             customermodify.Street    = customer.Street;
             customermodify.Postal    = customer.Postal;
             customermodify.Country   = customer.Country;
             customermodify.City      = customer.City;
             customersRepo.Update(customermodify);
             uow.SaveChanges();
             return(RedirectToAction("Details", new { @id = customer.Id }));
         }
     }
     using (var uow = new UoW()){
         //ViewBag.CreatorId = new SelectList(uow.IdentityUsers.GetAll(), "Id", "UserName");
     }
     return(View(customer));
 }
Ejemplo n.º 2
0
 // GET: /Customer/
 public ActionResult Index()
 {
     Log.Debug("GET/Index");
     using (var uow = new UoW()){
         var customersRepo = uow.GetRepository <ICustomerRepository>();
         var customers     = customersRepo.GetQuery().Include(c => c.Creator).ToList();
         return(View("Index", (object)JsonConvert.SerializeObject(customers)));
     }
 }
Ejemplo n.º 3
0
        // GET: /Product/

        #region Methods
        public ActionResult Index()
        {
            Log.Debug("GET/Index");
            using (var uow = new UoW())
            {
                var productsRepo = uow.GetRepository<IProductRepository>();
                var products = productsRepo.GetQuery().Include(p => p.Creator).ToList();
                return View("Index", (object)JsonConvert.SerializeObject(products));
            }
        }
        // GET: /Product/

        #region Methods
        public ActionResult Index()
        {
            Log.Debug("GET/Index");
            using (var uow = new UoW())
            {
                var productsRepo = uow.GetRepository <IProductRepository>();
                var products     = productsRepo.GetQuery().Include(p => p.Creator).ToList();
                return(View("Index", (object)JsonConvert.SerializeObject(products)));
            }
        }
Ejemplo n.º 5
0
        // GET: /License/

        #region Methods
        public ActionResult Index()
        {
            Log.Debug("GET/Index");
            using (var uow = new UoW())
            {
                var licensesRepo = uow.GetRepository <ILicensePocoRepository>();
                var licenses     = licensesRepo.GetQuery().Include(l => l.Creator).Include(l => l.Customer).Include(l => l.Product).ToList();
                return(View("Index", (object)JsonConvert.SerializeObject(licenses)));
            }
        }
Ejemplo n.º 6
0
 public ActionResult DeleteConfirmed(int id)
 {
     Log.Debug("POST/DeleteConfirmed Id:{0}", id.ToString());
     using (var uow = new UoW()){
         var customersRepo = uow.GetRepository <ICustomerRepository>();
         var customer      = customersRepo.GetByKey((System.Int32)id);
         customersRepo.Delete(customer);
         uow.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
        // GET: /License/

        #region Methods
        public ActionResult Index()
        {
            Log.Debug("GET/Index");
            using (var uow = new UoW())
            {
                var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
                var licenses = licensesRepo.GetQuery().Include(l => l.Creator).Include(l => l.Customer).Include(l => l.Product).ToList();
                return View("Index", (object)JsonConvert.SerializeObject(licenses));

            }
        }
Ejemplo n.º 8
0
 public ActionResult DeleteConfirmed(int id)
 {
     Log.Debug("POST/DeleteConfirmed Id:{0}", id.ToString());
     using (var uow = new UoW())
     {
         var licensesRepo = uow.GetRepository <ILicensePocoRepository>();
         var licensepoco  = licensesRepo.GetByKey((System.Int32)id);
         licensesRepo.Delete(licensepoco);
         uow.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,PassPhrase,PrivateKey,PublicKey,CreationDate,CreatorId")] Product product)
 {
     Log.Debug("POST/Edit");
     if (ModelState.IsValid)
     {
         using (var uow = new UoW())
         {
             var productsRepo  = uow.GetRepository <IProductRepository>();
             var modifyproduct = productsRepo.GetByKey(product.Id);
             modifyproduct.Name = product.Name;
             productsRepo.Update(modifyproduct);
             uow.SaveChanges();
             return(RedirectToAction("Details", new { @id = product.Id }));
         }
     }
     return(View(product));
 }
 public ActionResult Create([Bind(Include = "Id,Name,PassPhrase,PrivateKey,PublicKey,CreationDate,CreatorId")] Product product)
 {
     Log.Debug("POST/Create");
     if (ModelState.IsValid)
     {
         using (var uow = new UoW())
         {
             var productsRepo = uow.GetRepository <IProductRepository>();
             _licenseGenerationService.GeneratePassPhraseForProduct(product);
             _licenseGenerationService.GenerateKeysForProduct(product);
             productsRepo.Add(product);
             uow.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Ejemplo n.º 11
0
 public void For_An_Invalid_Type_Must_Return_NULL_Repository()
 {
     //
     // Arrange
     //
     var mockContext = new Mock<EFDbContext>();
     var mockRepoFactory = new Mock<IRepositoryFactory>();
     mockRepoFactory.Setup(x => x.GetRepository<IModel>()).Returns((IRepository<IModel>) null);
     var uow = new UoW(mockContext.Object, mockRepoFactory.Object);
     //
     // Act
     //
     var result = uow.GetRepository<IModel>();
     //
     // Assert
     //
     Assert.IsNull(result);
 }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Company,Email,City,Postal,Street,Country,CreatorId,ModificationDate,CreationDate")] Customer customer)
        {
            Log.Debug("POST/Create");
            if (ModelState.IsValid)
            {
                using (var uow = new UoW()){
                    var customersRepo = uow.GetRepository <ICustomerRepository>();
                    customersRepo.Add(customer);
                    uow.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            using (var uow = new UoW()){
                //ViewBag.CreatorId = new SelectList(uow.IdentityUsers.GetAll(), "Id", "UserName");
            }
            return(View(customer));
        }
Ejemplo n.º 13
0
 // GET: /Product/Details/5
 public ActionResult Details(int? id)
 {
     Log.Debug("GET/Details id: {0}", id.ToString());
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Product product = null;
     using (var uow = new UoW())
     {
         var productsRepo = uow.GetRepository<IProductRepository>();
         product = productsRepo.GetByKey((System.Int32) id);
     }
     if (product == null)
     {
         return HttpNotFound();
     }
     return View(product);
 }
Ejemplo n.º 14
0
        // GET: /Customer/Details/5
        public ActionResult Details(int?id)
        {
            Log.Debug("GET/Details id: {0}", id.ToString());
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Customer customer = null;

            using (var uow = new UoW()){
                var customersRepo = uow.GetRepository <ICustomerRepository>();
                customer = customersRepo.GetByKey((System.Int32)id);
            }
            if (customer == null)
            {
                return(HttpNotFound());
            }
            return(View(customer));
        }
        // GET: /Product/Details/5
        public ActionResult Details(int?id)
        {
            Log.Debug("GET/Details id: {0}", id.ToString());
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product product = null;

            using (var uow = new UoW())
            {
                var productsRepo = uow.GetRepository <IProductRepository>();
                product = productsRepo.GetByKey((System.Int32)id);
            }
            if (product == null)
            {
                return(HttpNotFound());
            }
            return(View(product));
        }
Ejemplo n.º 16
0
        // GET: /License/Edit/5
        //public ActionResult Edit(int? id)
        //{
        //    Log.Debug("GET/Edit id:{0}", id.ToString());
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    LicensePoco licensepoco = null;
        //    using (var uow = new UoW())
        //    {
        //        var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
        //        licensepoco = licensesRepo.GetByKey((System.Int32) id);
        //    }
        //    if (licensepoco == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    using (var uow = new UoW())
        //    {
        //        ViewBag.CustomerId = new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
        //        ViewBag.ProductId = new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
        //    }
        //    return View(licensepoco);
        //}

        //// POST: /License/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "Id,Value,ExpireVersion,ExpireDate,CustomerId,ProductId,CreatorId,ModificationDate,CreationDate")] LicensePoco licensepoco)
        //{
        //    Log.Debug("POST/Edit");
        //    if (ModelState.IsValid)
        //    {
        //        using (var uow = new UoW())
        //        {
        //            var licensesRepo = uow.GetRepository<ILicensePocoRepository>();

        //            licensesRepo.Update(licensepoco);
        //            uow.SaveChanges();
        //        }
        //    }
        //    using (var uow = new UoW())
        //    {
        //        ViewBag.CustomerId = new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
        //        ViewBag.ProductId = new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
        //    }
        //    return View(licensepoco);
        //}

        // GET: /License/Delete/5
        public ActionResult Delete(int?id)
        {
            Log.Debug("GET/Delete Id:{0}, id.ToString()");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LicensePoco licensepoco = null;

            using (var uow = new UoW())
            {
                var licensesRepo = uow.GetRepository <ILicensePocoRepository>();
                licensepoco = licensesRepo.GetByKey((System.Int32)id);
            }
            if (licensepoco == null)
            {
                return(HttpNotFound());
            }
            return(View(licensepoco));
        }
 // GET: /License/Details/5
 public ActionResult Details(int? id)
 {
     Log.Debug("GET/Details id: {0}", id.ToString());
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     LicensePoco licensepoco = null;
     using (var uow = new UoW())
     {
         var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
       //  licensepoco = licensesRepo.GetByKey((System.Int32) id); // Geert mayby add include?
         licensepoco = licensesRepo.GetQuery().Include(x=>x.Customer).Include(x=>x.Product).FirstOrDefault(x => x.Id == (System.Int32) id);
     }
     if (licensepoco == null)
     {
         return HttpNotFound();
     }
     return View(licensepoco);
 }
Ejemplo n.º 18
0
 Cart ICartService.GetCart()
 {
     return(new Cart
     {
         Items = new List <CartItem>
         {
             new CartItem
             {
                 CartItemId = 9,
                 Book = UoW.GetRepository <Book>().GetAll().ToList()[0],
                 Count = 2
             },
             new CartItem
             {
                 CartItemId = 39,
                 Book = UoW.GetRepository <Book>().GetAll().ToList()[3],
                 Count = 1
             }
         }
     });
 }
Ejemplo n.º 19
0
        // GET: /License/Details/5
        public ActionResult Details(int?id)
        {
            Log.Debug("GET/Details id: {0}", id.ToString());
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LicensePoco licensepoco = null;

            using (var uow = new UoW())
            {
                var licensesRepo = uow.GetRepository <ILicensePocoRepository>();
                //  licensepoco = licensesRepo.GetByKey((System.Int32) id); // Geert mayby add include?
                licensepoco = licensesRepo.GetQuery().Include(x => x.Customer).Include(x => x.Product).FirstOrDefault(x => x.Id == (System.Int32)id);
            }
            if (licensepoco == null)
            {
                return(HttpNotFound());
            }
            return(View(licensepoco));
        }
Ejemplo n.º 20
0
        // GET: /Customer/Edit/5
        public ActionResult Edit(int?id)
        {
            Log.Debug("GET/Edit id:{0}", id.ToString());
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Customer customer = null;

            using (var uow = new UoW()){
                var customersRepo = uow.GetRepository <ICustomerRepository>();
                customer = customersRepo.GetByKey((System.Int32)id);
            }
            if (customer == null)
            {
                return(HttpNotFound());
            }
            using (var uow = new UoW()){
                //ViewBag.CreatorId = new SelectList(uow.IdentityUsers.GetAll(), "Id", "UserName");
            }
            return(View(customer));
        }
Ejemplo n.º 21
0
        public ActionResult Create([Bind(Include = "Id,Value,ExpireVersion,ExpireDate,CustomerId,ProductId,CreatorId,ModificationDate,CreationDate")] LicensePoco licensepoco)
        {
            Log.Debug("POST/Create");
            if (ModelState.IsValid)
            {
                _licenseGenerationService.GenerateLicenseValue(licensepoco);
                using (var uow = new UoW())
                {
                    var licensesRepo = uow.GetRepository <ILicensePocoRepository>();
                    licensesRepo.Add(licensepoco);
                    uow.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            using (var uow = new UoW())
            {
                ViewBag.CustomerId = JsonConvert.SerializeObject(uow.Customers.GetAll().ToList()); // new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
                ViewBag.ProductId  = JsonConvert.SerializeObject(uow.Products.GetAll().ToList());  //new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
            }
            return(View(licensepoco));
        }
Ejemplo n.º 22
0
 IEnumerable <Genre> IStoreService.GetGenres()
 {
     return(UoW.GetRepository <Genre>().GetAll());
 }
Ejemplo n.º 23
0
 public ActionResult Create([Bind(Include = "Id,Name,PassPhrase,PrivateKey,PublicKey,CreationDate,CreatorId")] Product product)
 {
     Log.Debug("POST/Create");
     if (ModelState.IsValid)
     {
         using (var uow = new UoW())
         {
             var productsRepo = uow.GetRepository<IProductRepository>();
             _licenseGenerationService.GeneratePassPhraseForProduct(product);
             _licenseGenerationService.GenerateKeysForProduct(product);
             productsRepo.Add(product);
             uow.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(product);
 }
Ejemplo n.º 24
0
        public void For_A_Valid_Type_Must_Return_Repository_With_UoW()
        {
            //
            // Arrange
            //
            var mockRepository = new Mock<IRepository<IModel>>();

            var mockContext = new Mock<EFDbContext>();
            var mockRepoFactory = new Mock<IRepositoryFactory>();
            mockRepoFactory.Setup(x => x.GetRepository<IModel>()).Returns(mockRepository.Object);
            var uow = new UoW(mockContext.Object, mockRepoFactory.Object);
            //
            // Act
            //
            var result = uow.GetRepository<IModel>();
            //
            // Assert
            //
            Assert.IsNotNull(result);
            mockRepository.VerifySet(x=>x.UoW = It.IsAny<IUoW>(), Times.Once());
        }
Ejemplo n.º 25
0
 IEnumerable <Author> IStoreService.GetAuthors()
 {
     return(UoW.GetRepository <Author>().GetAll());
 }
        public ActionResult Create([Bind(Include = "Id,Value,ExpireVersion,ExpireDate,CustomerId,ProductId,CreatorId,ModificationDate,CreationDate")] LicensePoco licensepoco)
        {
            Log.Debug("POST/Create");
            if (ModelState.IsValid)
            {
                _licenseGenerationService.GenerateLicenseValue(licensepoco);
                using (var uow = new UoW())
                {
                    var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
                    licensesRepo.Add(licensepoco);
                    uow.SaveChanges();
                }
                return RedirectToAction("Index");
            }

            using (var uow = new UoW())
            {
                ViewBag.CustomerId = JsonConvert.SerializeObject(uow.Customers.GetAll().ToList()); // new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
                ViewBag.ProductId = JsonConvert.SerializeObject(uow.Products.GetAll().ToList());//new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
            }
            return View(licensepoco);
        }
        // GET: /License/Edit/5
        //public ActionResult Edit(int? id)
        //{
        //    Log.Debug("GET/Edit id:{0}", id.ToString());
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    LicensePoco licensepoco = null;
        //    using (var uow = new UoW())
        //    {
        //        var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
        //        licensepoco = licensesRepo.GetByKey((System.Int32) id);
        //    }
        //    if (licensepoco == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    using (var uow = new UoW())
        //    {
        //        ViewBag.CustomerId = new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
        //        ViewBag.ProductId = new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
        //    }
        //    return View(licensepoco);
        //}

        //// POST: /License/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "Id,Value,ExpireVersion,ExpireDate,CustomerId,ProductId,CreatorId,ModificationDate,CreationDate")] LicensePoco licensepoco)
        //{
        //    Log.Debug("POST/Edit");
        //    if (ModelState.IsValid)
        //    {
        //        using (var uow = new UoW())
        //        {
        //            var licensesRepo = uow.GetRepository<ILicensePocoRepository>();

        //            licensesRepo.Update(licensepoco);
        //            uow.SaveChanges();
        //        }
        //    }
        //    using (var uow = new UoW())
        //    {
        //        ViewBag.CustomerId = new SelectList(uow.Customers.GetAll().ToList(), "Id", "FirstName");
        //        ViewBag.ProductId = new SelectList(uow.Products.GetAll().ToList(), "Id", "Name");
        //    }
        //    return View(licensepoco);
        //}

        // GET: /License/Delete/5
        public ActionResult Delete(int? id)
        {
            Log.Debug("GET/Delete Id:{0}, id.ToString()");
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            LicensePoco licensepoco = null;
            using (var uow = new UoW())
            {
                var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
                licensepoco = licensesRepo.GetByKey((System.Int32) id);
            }
            if (licensepoco == null)
            {
                return HttpNotFound();
            }
            return View(licensepoco);
        }
Ejemplo n.º 28
0
 Author IStoreService.GetAuthorById(int authorId)
 {
     return(UoW.GetRepository <Author>().GetById(authorId));
 }
Ejemplo n.º 29
0
 void IStoreService.Update(Genre genre)
 {
     UoW.GetRepository <Genre>().Update(genre);
     UoW.Save();
 }
Ejemplo n.º 30
0
 void IStoreService.Add(Book book)
 {
     UoW.GetRepository <Book>().Add(book);
     UoW.Save();
 }
Ejemplo n.º 31
0
 Genre IStoreService.GetGenreById(int genreId)
 {
     return(UoW.GetRepository <Genre>().GetById(genreId));
 }
Ejemplo n.º 32
0
 void IStoreService.Add(Author author)
 {
     UoW.GetRepository <Author>().Add(author);
     UoW.Save();
 }
Ejemplo n.º 33
0
 void IStoreService.Add(Genre genre)
 {
     UoW.GetRepository <Genre>().Add(genre);
     UoW.Save();
 }
Ejemplo n.º 34
0
 void IStoreService.Delete(Book book)
 {
     UoW.GetRepository <Book>().Delete(book);
     UoW.Save();
 }
Ejemplo n.º 35
0
 public ActionResult DeleteConfirmed(int id)
 {
     Log.Debug("POST/DeleteConfirmed Id:{0}", id.ToString());
     using (var uow = new UoW())
     {
         var productsRepo = uow.GetRepository<IProductRepository>();
         var product = productsRepo.GetByKey((System.Int32) id);
         productsRepo.Delete(product);
         uow.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 36
0
 void IStoreService.DeleteGenreById(int id)
 {
     UoW.GetRepository <Genre>().Delete(id);
     UoW.Save();
 }
Ejemplo n.º 37
0
 public ActionResult Edit([Bind(Include = "Id,Name,PassPhrase,PrivateKey,PublicKey,CreationDate,CreatorId")] Product product)
 {
     Log.Debug("POST/Edit");
     if (ModelState.IsValid)
     {
         using (var uow = new UoW())
         {
             var productsRepo = uow.GetRepository<IProductRepository>();
             var modifyproduct = productsRepo.GetByKey(product.Id);
             modifyproduct.Name = product.Name;
             productsRepo.Update(modifyproduct);
             uow.SaveChanges();
             return RedirectToAction("Details", new { @id = product.Id});
         }
     }
     return View(product);
 }
Ejemplo n.º 38
0
 IEnumerable <Book> IStoreService.SearchBooks(string searchqry)
 {
     return(UoW.GetRepository <Book>().Find(x => x.Title.Contains(searchqry)));
 }
 public ActionResult DeleteConfirmed(int id)
 {
     Log.Debug("POST/DeleteConfirmed Id:{0}", id.ToString());
     using (var uow = new UoW())
     {
         var licensesRepo = uow.GetRepository<ILicensePocoRepository>();
         var licensepoco = licensesRepo.GetByKey((System.Int32) id);
         licensesRepo.Delete(licensepoco);
         uow.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 40
0
 IEnumerable <Book> IStoreService.GetBooksByGenre(int genreId)
 {
     return(UoW.GetRepository <Book>().Find(x => x.GenreId == genreId).OrderBy(x => x.Title));
 }
Ejemplo n.º 41
0
 Book IStoreService.GetBookById(int bookId)
 {
     return(UoW.GetRepository <Book>().GetById(bookId));
 }
Ejemplo n.º 42
0
 IEnumerable <Book> IStoreService.GetBooksByAuthor(int authorId)
 {
     return(UoW.GetRepository <Book>().Find(x => x.AuthorId == authorId).OrderBy(x => x.Title));
 }