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)); }
// 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))); } }
// 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))); } }
// 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))); } }
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)); } }
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)); }
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); }
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)); }
// 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); }
// 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)); }
// 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); }
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 } } }); }
// 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)); }
// 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)); }
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)); }
IEnumerable <Genre> IStoreService.GetGenres() { return(UoW.GetRepository <Genre>().GetAll()); }
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); }
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()); }
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); }
Author IStoreService.GetAuthorById(int authorId) { return(UoW.GetRepository <Author>().GetById(authorId)); }
void IStoreService.Update(Genre genre) { UoW.GetRepository <Genre>().Update(genre); UoW.Save(); }
void IStoreService.Add(Book book) { UoW.GetRepository <Book>().Add(book); UoW.Save(); }
Genre IStoreService.GetGenreById(int genreId) { return(UoW.GetRepository <Genre>().GetById(genreId)); }
void IStoreService.Add(Author author) { UoW.GetRepository <Author>().Add(author); UoW.Save(); }
void IStoreService.Add(Genre genre) { UoW.GetRepository <Genre>().Add(genre); UoW.Save(); }
void IStoreService.Delete(Book book) { UoW.GetRepository <Book>().Delete(book); UoW.Save(); }
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"); }
void IStoreService.DeleteGenreById(int id) { UoW.GetRepository <Genre>().Delete(id); UoW.Save(); }
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); }
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"); }
IEnumerable <Book> IStoreService.GetBooksByGenre(int genreId) { return(UoW.GetRepository <Book>().Find(x => x.GenreId == genreId).OrderBy(x => x.Title)); }
Book IStoreService.GetBookById(int bookId) { return(UoW.GetRepository <Book>().GetById(bookId)); }
IEnumerable <Book> IStoreService.GetBooksByAuthor(int authorId) { return(UoW.GetRepository <Book>().Find(x => x.AuthorId == authorId).OrderBy(x => x.Title)); }