public async Task <IActionResult> CheckOut(int id, ComponentVM dataFromView)
        {
            //bool exito = await _helperService.UpdateCheckOutFieldOfCurrentOrderAsync(true);
            await _helperService.DeleteOrderByCheckOutValueAsync(false);

            return(RedirectToAction(nameof(Index), "Home"));
        }
        public ActionResult Create(ComponentVM data)
        {
            var model = _mapper.Map <ComponentVM, Component>(data);

            _componentRepo.Insert(model);
            return(RedirectToAction(nameof(Index), "Component"));
        }
        // GET: /Component/Create
        public ViewResult Create()
        {
            ViewBag.ComponentTypeList   = ComponentTypesSelectList();
            ViewBag.ComponentStatusList = ComponentStatusEnumSelectList();
            var VM = new ComponentVM();

            return(View(VM));
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializedComponentVM"/> class.
        /// </summary>
        /// <param name="baseVm">The base view model.</param>
        /// <param name="assemblyPath">The assembly path.</param>
        public SerializedComponentVM(ComponentVM baseVm, string assemblyPath)
        {
            this.XPos         = baseVm.XCoord;
            this.YPos         = baseVm.YCoord;
            this.AssemblyPath = assemblyPath;
            this.UniqueName   = baseVm.Identifier;
            var temp  = new List <int>(baseVm.InputPinsVM.ToList().Select(x => x.IDNumber).ToList());
            var temp2 = new List <int>(baseVm.OutputPinsVM.ToList().Select(x => x.IDNumber).ToList());

            temp2.AddRange(temp);
            this.InputPutputIDs = temp2.ToArray();
        }
Example #5
0
        public ActionResult Create([Bind(Include = "ComponentTypeId,ModelName,Name,Description,Price,InventNumber,Supplier")] ComponentVM componentVM)
        {
            if (ModelState.IsValid)
            {
                ComponentDTO componentDTO = Mapper.Map <ComponentDTO>(componentVM);
                ComponentService.Add(componentDTO);

                return(RedirectToAction("Index"));
            }
            ViewBag.ComponentTypeId = GetComponentTypeIdSelectList();

            return(View(componentVM));
        }
        public double GetComputerTotalPrice(ComponentVM dataFromView)
        {
            Type type            = typeof(ComponentVM);
            int  NumberOfRecords = type.GetProperties().Length;

            int[]     idArray    = new int[NumberOfRecords];
            double    totalPrice = 0;
            Component component  = new Component();

            idArray[0] = dataFromView.HddId; idArray[1] = dataFromView.SoftwareId; idArray[2] = dataFromView.ProcessorId; idArray[3] = dataFromView.MemoryId; idArray[4] = dataFromView.OSId;
            foreach (int item in idArray)
            {
                component   = _context.Component.Where(c => c.Id == item).FirstOrDefault <Component>();
                totalPrice += component.Price;
            }
            return(totalPrice);
        }
        public ActionResult Edit(int id, ComponentVM data)
        {
            // Nasty hack because we are dependent on the Entity framework proxy classes in the
            // Repository.
            var model      = _componentRepo.Get(id);
            var dataMapped = _mapper.Map <ComponentVM, Component>(data);

            model.AdminComment    = dataMapped.AdminComment;
            model.ComponentNumber = dataMapped.ComponentNumber;
            model.ComponentTypeId = dataMapped.ComponentTypeId;
            model.SerialNo        = dataMapped.SerialNo;
            model.Status          = dataMapped.Status;
            model.UserComment     = dataMapped.UserComment;

            _componentRepo.Update(model);
            return(RedirectToAction(nameof(Index), "Component"));
        }
        //public void BuildComputer(string ProcessorId, string MemoryId, string Hdd, string Software)
        public async Task <IActionResult> BuildComputer(ComponentVM dataFromView)
        {
            Order             order             = new Order();
            Computer          computer          = new Computer();
            ComputerComponent computerComponent = new ComputerComponent();

            int     orderId       = 0;
            AppUser myCurrentUser = await _userManager.GetUserAsync(User);

            if (myCurrentUser == null)
            {
                //return NotFound();
                ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                return(RedirectToAction(nameof(Index)));
            }

            Order orderAssociatedWUser = await _orderService.GetOrderItemAsync(false);

            //.ToListAsync();

            if (orderAssociatedWUser == null)
            {
                order.Price    += _helperService.GetComputerTotalPrice(dataFromView);
                order.Qty       = 1;
                order.IsCart    = false;
                order.AppUserId = myCurrentUser.Id;
                orderId         = await _helperService.InsertOrderToDBAsync(order);
            }
            else
            {
                orderId = orderAssociatedWUser.Id;
            }

            computer.Name      = _helperService.CUSTOM_COMPUTER_NAME;
            computer.Price     = _helperService.GetComputerTotalPrice(dataFromView);
            computer.IsDesktop = true;
            computer.ImgUrl    = "https://c1.neweggimages.com/NeweggImage/ProductImage/83-221-575-V09.jpg";
            int computerId = await _helperService.InsertComputerToDBAsync(computer);

            int computerComponentId = await _helperService.InsertComponentsToComputerComponentDBAsync(dataFromView, computerId, orderId);

            int computerOrderId = await _helperService.InsertComputerOrderToDBAsync(orderId, computerId);

            return(RedirectToAction(nameof(Index)));
        }
Example #9
0
        public async Task <ComponentVM> SearchAsync(ComponentVM componentVM)
        {
            var filters = new Filters <Component>();

            filters.Add(!string.IsNullOrEmpty(componentVM.NameAr), u => u.NameAr.Contains(componentVM.NameAr));
            filters.Add(!string.IsNullOrEmpty(componentVM.NameEn), u => u.NameEn.Contains(componentVM.NameEn));

            var result = await _dbContext.Components.AsNoTracking().Paginate(componentVM.PageNumber, componentVM.PageSize, filters);

            componentVM.ComponentsList =
                new StaticPagedList <Component>(
                    result.Results,
                    result.CurrentPage,
                    result.PageSize,
                    result.RecordCount);

            return(componentVM);
        }
Example #10
0
        public ActionResult Details(Guid?id)
        {
            try
            {
                ComponentDTO componentDTO = ComponentService.Get((Guid)id);
                ComponentVM  componentVM  = Mapper.Map <ComponentVM>(componentDTO);

                return(View(componentVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
        //public void BuildComputer(string ProcessorId, string MemoryId, string Hdd, string Software)
        public async Task <IActionResult> BuildComputerEdit(int id, ComponentVM dataFromView)
        {
            Type type            = typeof(ComponentVM);
            int  NumberOfRecords = type.GetProperties().Length;

            int[] idArray = new int[NumberOfRecords];

            Computer computer = await _context.Computer
                                .Where(computer => computer.Id == id)
                                .Include(component => component.ComputerComponents)
                                .SingleOrDefaultAsync();

            if (id != computer.Id)
            {
                return(NotFound());
            }
            computer.Price = _helperService.GetComputerTotalPrice(dataFromView);

            idArray[0] = dataFromView.HddId; idArray[1] = dataFromView.SoftwareId; idArray[2] = dataFromView.ProcessorId; idArray[3] = dataFromView.MemoryId; idArray[4] = dataFromView.OSId;
            int i = 0;

            foreach (var item in computer.ComputerComponents)
            {
                item.ComponentId = idArray[i++];
            }

            try
            {
                _context.Update(computer);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ComputerExists(computer.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Example #12
0
        public ActionResult Edit(Guid?id)
        {
            try
            {
                ComponentDTO componentDTO = ComponentService.Get(id);
                ComponentVM  componentVM  = Mapper.Map <ComponentVM>(componentDTO);
                ViewBag.ComponentTypeId = GetComponentTypeIdSelectList(componentVM.ComponentTypeId);

                return(View(componentVM));
            }
            catch (ArgumentNullException)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            catch (NotFoundException)
            {
                return(HttpNotFound());
            }
        }
        public async Task <int> InsertComponentsToComputerComponentDBAsync(ComponentVM component, int computerId, int orderId)
        {
            Type type            = typeof(ComponentVM);
            int  NumberOfRecords = type.GetProperties().Length;

            int[] idArray = new int[NumberOfRecords];

            ComputerComponent computerComponent = new ComputerComponent();

            idArray[0] = component.HddId; idArray[1] = component.SoftwareId; idArray[2] = component.ProcessorId; idArray[3] = component.MemoryId; idArray[4] = component.OSId;
            //computerComponent.ComputerId = computerId;
            foreach (var item in idArray)
            {
                computerComponent             = new ComputerComponent();
                computerComponent.ComputerId  = computerId;
                computerComponent.ComponentId = item;
                //computerComponent.OrderId = orderId;
                _context.Add(computerComponent);
                await _context.SaveChangesAsync();
            }

            return(computerComponent.Id);
        }
Example #14
0
 protected async Task GetComponents()
 {
     componentVM = await _componentService.SearchComponentAsync(componentVM);
 }
Example #15
0
 protected async Task SearchComponent()
 {
     Page = "1";
     componentVM.PageNumber = 1;
     componentVM            = await _componentService.SearchComponentAsync(componentVM);
 }
Example #16
0
 public VisibleMessagesWindow(ComponentVM vm)
 {
     this.DataContext = new VisibleMessagesVM(vm);
     InitializeComponent();
 }