Exemplo n.º 1
0
        public async void AddOrUpdate(int index, int?id, string name)
        {
            if (id != null) // Update
            {
                Cat  value   = new Cat(id, name);
                bool reusult = await catRepo.Update((int)id, value);

                if (reusult)
                {
                    cats[index] = value;
                    message     = MessageHelper.Get("up");
                }
                else
                {
                    message = MessageHelper.Get("upErr");
                }
            }
            else // Add
            {
                Cat value = new Cat(null, name);
                id = await catRepo.Add(value);

                if (id != 0)
                {
                    value.ID = (int)id;
                    cats.Add(value);
                    message = MessageHelper.Get("add");
                }
                else
                {
                    message = MessageHelper.Get("addErr");
                }
            }
        }
Exemplo n.º 2
0
 public ActionResult Create(VMCategoryInfo category)
 {
     if (ModelState.IsValid)
     {
         catDB.Add(category);
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Exemplo n.º 3
0
 public async Task Add(CatDTO cat)
 {
     await _repository.Add(_mapper.mapper.Map <Cat>(cat));
 }
Exemplo n.º 4
0
 public void AddCat(Cat cat)
 {
     catRepository.Add(cat);
 }