Esempio n. 1
0
 public async Task CreateAsync(Category2Model model)
 {
     model.ID    = Guid.NewGuid();
     model.Image = "";
     Category2.Create(_mapper.Map <Category2Entity>(model));
     await Category2.SaveAsync();
 }
        public async Task <IActionResult> Create([Bind("ID,Code,Description,Cat1ID")] Category2Model Category2)
        {
            if (ModelState.IsValid)
            {
                await _Category2Service.CreateAsync(Category2);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category1"] = new SelectList(await _Category1Service.GetAllAsync(), "ID", "Description");
            return(View(Category2));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,Code,Description,Cat1ID,RowVersion")] Category2Model Category2)
        {
            if (id != Category2.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _Category2Service.UpdateAsync(Category2);

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