Ejemplo n.º 1
0
 public async Task CreateAsync(Category3Model model)
 {
     model.ID    = Guid.NewGuid();
     model.Image = "";
     Category3.Create(_mapper.Map <Category3Entity>(model));
     await Category3.SaveAsync();
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Code,Description,Cat2ID")] Category3Model Category3)
        {
            if (ModelState.IsValid)
            {
                await _Category3Service.CreateAsync(Category3);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category2"] = new SelectList(await _Category2Service.GetAllAsync(), "ID", "Description");
            return(View(Category3));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,Code,Description,Cat2ID,RowVersion")] Category3Model Category3)
        {
            if (id != Category3.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _Category3Service.UpdateAsync(Category3);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    ViewBag.Message = "Record has been modified by someone else.";
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category2"] = new SelectList(await _Category2Service.GetAllAsync(), "ID", "Description");
            return(View(Category3));
        }
Ejemplo n.º 4
0
 public async Task UpdateAsync(Category3Model model)
 {
     Category3.Update(_mapper.Map <Category3Entity>(model));
     await Category3.SaveAsync();
 }