Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ItemDepartment itemDepartment = db.ItemDepartments.Find(id);

            db.ItemDepartments.Remove(itemDepartment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public Task <ItemDepartment> AddItemDepartment(ItemDepartment itemDepartment)
        {
            var itemDeptToAdd = new ItemDepartment
            {
                DeptName = itemDepartment.DeptName
            };

            _context.ItemDepartment.Add(itemDeptToAdd);
            _context.SaveChanges();

            return(null);
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,TaskItemId,DepartmentId,IsImpacted,UserId,ItemNumber")] ItemDepartment itemDepartment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemDepartment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Department_Name", itemDepartment.DepartmentId);
     ViewBag.TaskItemId   = new SelectList(db.TaskItems, "Id", "MandateComment", itemDepartment.TaskItemId);
     ViewBag.UserId       = new SelectList(db.Users, "Id", "UserIdentifier", itemDepartment.UserId);
     return(View(itemDepartment));
 }
Esempio n. 4
0
        // GET: ItemDepartments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ItemDepartment itemDepartment = db.ItemDepartments.Find(id);

            if (itemDepartment == null)
            {
                return(HttpNotFound());
            }
            return(View(itemDepartment));
        }
        public AdminControllerIntegrationTests()
        {
            #region MockData
            Manufacturer manufacturer = new Manufacturer
            {
                /* Id = 1,*/
                Name = "manufacturerName"
            };

            ItemDepartment itemDept = new ItemDepartment
            {
                /*   Id = 1,*/
                DeptName = "DeptName"
            };

            ItemType itemType = new ItemType
            {
                /* Id = 1,*/
                Name = "itemTypeName",
                ItemTypeHeaderImageUrl = "itemTypeHeaderImageUrl",
                ItemGroupName          = "itemGroupName"
            };

            ItemTypeSub itemSubType = new ItemTypeSub
            {
                /*   Id = 1,*/
                SubTypeName = "itemSubTypeName",
                ItemType    = itemType
            };

            Specs spec = new Specs
            {
                /*  Id = 1, */
                Description   = "Description",
                Specification = "Specification",
            };

            Model model = new Model
            {
                /*  Id = 1,*/
                ItemDepartment = itemDept,
                SpecsId        = spec,
                TypeId         = itemType,
                Name           = "modelName"
            };

            Items item = new Items
            {
                /* Id = 1, */
                Availability = 1,
                Color        = "itemColor",
                Price        = 12,
                Discount     = 0,
                ManuModel    = manufacturer,
                Model        = model,
                ItemTypeSub  = itemSubType
            };

            Reviews review = new Reviews
            {
                /*    Id = 1,*/
                /*  DayOfReview = DateTime.UtcNow,*/
                Item   = item,
                Rating = 5.0,
                Text   = "reviewText"
            };

            ImageUrls imageUrl = new ImageUrls
            {
                /* Id = 1,*/
                Item = item,
                Url  = "imageUrl"
            };
            #endregion

            adminModel = new AdminModel
            {
                Availibility   = item.Availability,
                Price          = item.Price,
                Discount       = item.Discount,
                Manufacturer   = manufacturer,
                Model          = model,
                ImageUrls      = imageUrl.Url,
                Color          = item.Color,
                ItemSubType    = itemSubType,
                ItemDepartment = itemDept,
                ModelName      = model.Name,
                Specs          = spec,
                ItemType       = itemType,
                Review         = review
            };


            var provider = new ServiceCollection().AddEntityFrameworkSqlServer().BuildServiceProvider();

            var options = new DbContextOptionsBuilder <StoreContext>();

            options.UseSqlServer($"Server=(localdb)\\MSSQLLocalDB;Database=Store_DTB_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=True; ")
            .UseInternalServiceProvider(provider).EnableSensitiveDataLogging();

            _context = new StoreContext(options.Options);
            _context.Database.Migrate();
        }
Esempio n. 6
0
        public void OrderController_AddInvoice_Success()
        {
            #region MockData
            Users user = new Users {
                UserName = "******", Email = "fakeEmail"
            };
            var cancel = new CancellationToken();

            var User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
            }));

            BillingInfo billingInfo = new BillingInfo
            {
                Adress         = "fakeAdress",
                City           = "fakeCity",
                CountryOrState = "fakeCountry",
                Email          = "fakeEmail",
                PhoneNumber    = "fakeNumber",
            };

            Invoice invoice = new Invoice
            {
                InvoiceDate = DateTimeOffset.UtcNow,
                UserId      = 1
            };

            Manufacturer manufacturer = new Manufacturer
            {
                /* Id = 1,*/
                Name = "manufacturerName"
            };

            ItemDepartment itemDept = new ItemDepartment
            {
                /*   Id = 1,*/
                DeptName = "DeptName"
            };

            ItemType itemType = new ItemType
            {
                /* Id = 1,*/
                Name = "itemTypeName",
                ItemTypeHeaderImageUrl = "itemTypeHeaderImageUrl",
                ItemGroupName          = "itemGroupName"
            };

            ItemTypeSub itemSubType = new ItemTypeSub
            {
                /*   Id = 1,*/
                SubTypeName = "itemSubTypeName",
                ItemType    = itemType
            };

            Specs spec = new Specs
            {
                /*  Id = 1, */
                Description   = "Description",
                Specification = "Specification",
            };

            Model model = new Model
            {
                /*  Id = 1,*/
                ItemDepartment = itemDept,
                SpecsId        = spec,
                TypeId         = itemType,
                Name           = "modelName"
            };

            Items item = new Items
            {
                /* Id = 1, */
                Availability = 1,
                Color        = "itemColor",
                Price        = 12,
                Discount     = 0,
                ManuModel    = manufacturer,
                Model        = model,
                ItemTypeSub  = itemSubType
            };

            PaymentMethod paymentMethod = new PaymentMethod {
                Method = "fakeMethod"
            };
            Status status = new Status {
                StatusText = "fakeStatus"
            };

            Order order = new Order
            {
                ItemId          = 1,
                UserId          = 1,
                NumberOfItems   = 1,
                StatusId        = 1,
                BillingInfoId   = 1,
                PaymentMethodId = 1,
                InvoiceId       = 1
            };
            #endregion

            OrderListModel addInvoiceModel = new OrderListModel {
                BillingInfoId = 1
            };

            var productService = new StoreProductService(_context);
            var userService    = new UserService(_context);
            var orderService   = new OrderService(_context);

            var mockUserStore = new Mock <IUserStore <Users> >();
            mockUserStore.Setup(u => u.CreateAsync(user, cancel));

            var manager    = new UserManager <Users>(mockUserStore.Object, null, null, null, null, null, null, null, null);
            var Controller = new OrderProcessingController(productService, manager, userService, orderService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = User
                    }
                }
            };

            var addUser          = userService.AddUser(user);
            var addItem          = productService.AddItem(item, spec, model);
            var addFirstInvoice  = orderService.AddInvoice(invoice);
            var addStatus        = orderService.AddStatus(status);
            var addStatus2       = orderService.AddStatus(status);
            var addStatus3       = orderService.AddStatus(status);
            var addStatus4       = orderService.AddStatus(status);
            var addPaymentMethod = orderService.AddPaymentMethod(paymentMethod);
            var addBillInfo      = orderService.AddBillingInfo(billingInfo);
            var addOrder         = orderService.AddOrder(order);
            var addInvoice       = Controller.AddInvoice(addInvoiceModel);

            var lastInvoice = orderService.GetLastInvoice();

            Assert.Equal(2, lastInvoice.Id);
            var    jsonResult = Assert.IsType <JsonResult>(addInvoice);
            string json       = JsonConvert.SerializeObject(jsonResult.Value);
            Assert.NotEqual("Invoice Addition Failed !", json);
            Assert.NotEqual("Something went wrong!", json);
        }
Esempio n. 7
0
        public void OrderController_ConfirmOrder_Success()
        {
            #region MockData
            Users user = new Users {
                UserName = "******", Email = "fakeEmail"
            };
            var cancel = new CancellationToken();

            var User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
            }));

            BillingInfo billingInfo = new BillingInfo
            {
                Adress         = "fakeAdress",
                City           = "fakeCity",
                CountryOrState = "fakeCountry",
                Email          = "fakeEmail",
                PhoneNumber    = "fakeNumber",
            };

            Invoice invoice = new Invoice
            {
                InvoiceDate = DateTimeOffset.UtcNow,
                UserId      = 1
            };

            Manufacturer manufacturer = new Manufacturer
            {
                /* Id = 1,*/
                Name = "manufacturerName"
            };

            ItemDepartment itemDept = new ItemDepartment
            {
                /*   Id = 1,*/
                DeptName = "DeptName"
            };

            ItemType itemType = new ItemType
            {
                /* Id = 1,*/
                Name = "itemTypeName",
                ItemTypeHeaderImageUrl = "itemTypeHeaderImageUrl",
                ItemGroupName          = "itemGroupName"
            };

            ItemTypeSub itemSubType = new ItemTypeSub
            {
                /*   Id = 1,*/
                SubTypeName = "itemSubTypeName",
                ItemType    = itemType
            };

            Specs spec = new Specs
            {
                /*  Id = 1, */
                Description   = "Description",
                Specification = "Specification",
            };

            Model model = new Model
            {
                /*  Id = 1,*/
                ItemDepartment = itemDept,
                SpecsId        = spec,
                TypeId         = itemType,
                Name           = "modelName"
            };

            Items item = new Items
            {
                /* Id = 1, */
                Availability = 1,
                Color        = "itemColor",
                Price        = 12,
                Discount     = 0,
                ManuModel    = manufacturer,
                Model        = model,
                ItemTypeSub  = itemSubType
            };

            PaymentMethod paymentMethod = new PaymentMethod {
                Method = "fakeMethod"
            };
            Status status = new Status {
                StatusText = "fakeStatus"
            };
            #endregion

            var productService = new StoreProductService(_context);
            var userService    = new UserService(_context);
            var orderService   = new OrderService(_context);

            var mockUserStore = new Mock <IUserStore <Users> >();
            mockUserStore.Setup(u => u.CreateAsync(user, cancel));

            var manager    = new UserManager <Users>(mockUserStore.Object, null, null, null, null, null, null, null, null);
            var Controller = new OrderController(productService, manager, userService, orderService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = User
                    }
                }
            };

            var addItem          = productService.AddItem(item, spec, model);
            var addUser          = userService.AddUser(user);
            var addInvoice       = orderService.AddInvoice(invoice);
            var addPaymentMethod = orderService.AddPaymentMethod(paymentMethod);
            var addStatus        = orderService.AddStatus(status);
            var addStatus2       = orderService.AddStatus(status);
            var addStatus3       = orderService.AddStatus(status);
            var addBillInfo      = orderService.AddBillingInfo(billingInfo);

            var addOrder      = Controller.AddOrder(productModel);
            var confirmOrders = Controller.ConfirmOrder();
            var getOrders     = orderService.GetAllOrders();
            Assert.Single(getOrders);
            Assert.Equal(3, getOrders.First().StatusId);
        }
Esempio n. 8
0
        public OrderControllerIntegrationTests()
        {
            #region MockData
            Manufacturer manufacturer = new Manufacturer
            {
                /* Id = 1,*/
                Name = "manufacturerName"
            };

            ItemDepartment itemDept = new ItemDepartment
            {
                /*   Id = 1,*/
                DeptName = "DeptName"
            };

            ItemType itemType = new ItemType
            {
                /* Id = 1,*/
                Name = "itemTypeName",
                ItemTypeHeaderImageUrl = "itemTypeHeaderImageUrl",
                ItemGroupName          = "itemGroupName"
            };

            ItemTypeSub itemSubType = new ItemTypeSub
            {
                /*   Id = 1,*/
                SubTypeName = "itemSubTypeName",
                ItemType    = itemType
            };

            Specs spec = new Specs
            {
                /*  Id = 1, */
                Description   = "Description",
                Specification = "Specification",
            };

            Model model = new Model
            {
                /*  Id = 1,*/
                ItemDepartment = itemDept,
                SpecsId        = spec,
                TypeId         = itemType,
                Name           = "modelName"
            };

            Items item = new Items
            {
                /* Id = 1, */
                Availability = 1,
                Color        = "itemColor",
                Price        = 12,
                Discount     = 0,
                ManuModel    = manufacturer,
                Model        = model,
                ItemTypeSub  = itemSubType
            };

            Reviews review = new Reviews
            {
                /*    Id = 1,*/
                /*  DayOfReview = DateTime.UtcNow,*/
                Item   = item,
                Rating = 5.0,
                Text   = "reviewText"
            };

            ImageUrls imageUrl = new ImageUrls
            {
                /* Id = 1,*/
                Item = item,
                Url  = "imageUrl"
            };

            BillingInfo billingInfo = new BillingInfo
            {
                Adress         = "fakeAdress",
                City           = "fakeCity",
                CountryOrState = "fakeCountry",
                Email          = "fakeEmail",
                PhoneNumber    = "fakeNumber",
            };
            #endregion

            productModel = new ProductModel
            {
                Review        = review,
                ItemId        = 1,
                UserId        = 1,
                NumberOfItems = 1,
                BillingInfoId = 1,
                InvoiceId     = 1
            };


            var provider = new ServiceCollection().AddEntityFrameworkSqlServer().BuildServiceProvider();

            var options = new DbContextOptionsBuilder <StoreContext>();

            options.UseSqlServer($"Server=(localdb)\\MSSQLLocalDB;Database=Store_DTB_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=True; ")
            .UseInternalServiceProvider(provider).EnableSensitiveDataLogging();

            _context = new StoreContext(options.Options);
            _context.Database.Migrate();
        }