Exemple #1
0
      public async Task <IActionResult> Edit(int id, [Bind("ID,Name,price")] Accessorie accessorie)
      {
          if (id != accessorie.ID)
          {
              return(NotFound());
          }

          if (ModelState.IsValid)
          {
              try
              {
                  _context.Update(accessorie);
                  await _context.SaveChangesAsync();
              }
              catch (DbUpdateConcurrencyException)
              {
                  if (!AccessorieExists(accessorie.ID))
                  {
                      return(NotFound());
                  }
                  else
                  {
                      throw;
                  }
              }
              return(RedirectToAction(nameof(Index)));
          }
          return(View(accessorie));
      }
Exemple #2
0
        public async Task <string> AddAccessoriesAsync(AddAccessorieInputModel model, string userId)
        {
            if (model.Name == null ||
                model.ImagePath == null)
            {
                throw new ArgumentNullException(ExceptionsServices.Null_PropertiesErrorMessage);
            }

            await this.productService.AddProductAsync(model.Name, model.Group, userId);

            var productId = this.productService.GetIdByNameAndGroup(model.Name, model.Group);
            var groupId   = this.groupService.FindByGroupName(model.Group).Id;

            var photoUrl = await this.cloudinaryService.UploadPhotoAsync(
                model.ImagePath,
                $"{model.Group}_{model.Name}_{model.Id}",
                GlobalConstants.CloudFolderForAccessoriesPhotos);

            var accessories = new Accessorie
            {
                Id          = Guid.NewGuid().ToString(),
                Description = model.Description,
                ImagePath   = photoUrl,
                ProductId   = productId,
                GroupId     = groupId,
                CreatedOn   = DateTime.UtcNow,
                ModifiedOn  = DateTime.UtcNow,
            };

            await this.accessoriesRepository.AddAsync(accessories);

            await this.accessoriesRepository.SaveChangesAsync();

            return(accessories.Id);
        }
Exemple #3
0
        public async Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.Accessories.Any())
            {
                return;
            }

            var acccs = AccessoriesConstants.Acces;
            var price = AccessoriesConstants.Price;

            var list = new List <Accessorie>();

            for (int i = 0; i < acccs.Length; i++)
            {
                var curr = new Accessorie
                {
                    AccessorieName = acccs[i],
                    PricePerUnit   = (decimal)price[i],
                    IsDeleted      = false,
                };

                list.Add(curr);
            }

            await dbContext.AddRangeAsync(list);

            await dbContext.SaveChangesAsync();
        }
Exemple #4
0
        public ViewModel()
        {
            String[] names = { "VAAN", "ASHE", "FRAN", "BALTHIER", "BASCH", "PENELO" };
            for (uint i = 0; i < names.Length; i++)
            {
                Party.Add(new Charactor(0x2210 + i * 456, names[i]));
            }

            for (uint i = 0; i < 64; i++)
            {
                Consumable.Add(new Item(0xDACC + i * 2, 0x6948, 0));
            }
            for (uint i = 0; i < 200; i++)
            {
                Weapon.Add(new Item(0xDB4C + i * 2, 0x69CA, 0x1001));
            }
            for (uint i = 0; i < 140; i++)
            {
                Armor.Add(new Item(0xDCDC + i * 2, 0x6B58, 0x10C8));
            }
            for (uint i = 0; i < 120; i++)
            {
                Accessorie.Add(new Item(0xDDF4 + i * 2, 0x6C70, 0x1154));
            }
            for (uint i = 0; i < 24; i++)
            {
                Technique.Add(new Technique(i));
            }
            for (uint i = 0; i < 81; i++)
            {
                Magic.Add(new Magic(i));
            }
        }
Exemple #5
0
      public async Task <IActionResult> Create([Bind("ID,Name,price")] Accessorie accessorie)
      {
          if (ModelState.IsValid)
          {
              _context.Add(accessorie);
              await _context.SaveChangesAsync();

              return(RedirectToAction(nameof(Index)));
          }
          return(View(accessorie));
      }
Exemple #6
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Accessorie = await _context.Accessorie.FirstOrDefaultAsync(m => m.ID == id);

            if (Accessorie == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Accessorie = await _context.Accessorie.FindAsync(id);

            if (Accessorie != null)
            {
                _context.Accessorie.Remove(Accessorie);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            string     webRootPath = _hostingEnvironment.WebRootPath;
            Accessorie accessorie  = await _db.Accessories.FindAsync(id);

            if (accessorie != null)
            {
                var imagePath = Path.Combine(webRootPath, accessorie.Image.TrimStart('\\'));

                if (System.IO.File.Exists(imagePath))
                {
                    System.IO.File.Delete(imagePath);
                }
                _db.Accessories.Remove(accessorie);
                await _db.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Index)));
        }