public IActionResult Remove(int[] categoryIds)
 {
     foreach (int categoryId in categoryIds)
     {
         MedicationCategory theCategory = context.Categories.Single(c => c.ID == categoryId);
         context.Categories.Remove(theCategory);
     }
     context.SaveChanges();
     return(Redirect("/Category"));
 }
 public IActionResult Add(AddCategoryViewModel addCategoryViewModel)
 {
     if (ModelState.IsValid)
     {
         MedicationCategory newCategory = new MedicationCategory
         {
             Name = addCategoryViewModel.Name
         };
         context.Categories.Add(newCategory);
         context.SaveChanges();
         return(Redirect("/Category"));
     }
     return(View(addCategoryViewModel));
 }
예제 #3
0
 public MedicationCategory Create(MedicationCategory entity)
 {
     if (!ExistsInSystem(entity))
     {
         var allCategories = stream.GetAll().ToList();
         allCategories.Add(entity);
         stream.SaveAll(allCategories);
         return(entity);
     }
     else
     {
         throw new EntityAlreadyExists(ALREADY_EXISTS);
     }
 }
 public MedicationCategory AddCategory(MedicationCategory category) => medicationCategoryService.AddCategory(category);
 public MedicationCategory AddCategory(MedicationCategory category) => medicationCategoryRepository.Create(category);
예제 #6
0
        public bool ExistsInSystem(MedicationCategory category)
        {
            var allCategories = stream.GetAll().ToList();

            return(allCategories.Any(item => item.CategoryName == category.CategoryName));
        }
예제 #7
0
    public static void FillMedicationCategoryDropdown(DropDownList ddMedicationCat)
    {
        MedicationCategory medicationCat = new MedicationCategory();
        DataSet dsMedicationCat = medicationCat.GetMedicationCategoryList();
        ddMedicationCat.DataSource = dsMedicationCat;
        ddMedicationCat.DataTextField = "MedicationCatDesc";
        ddMedicationCat.DataValueField = "MedicationCatCd";
        ddMedicationCat.DataBind();

        ListItem item = new ListItem();
        item.Value = "0";
        item.Text = "-Select Medication Category-";
        ddMedicationCat.Items.Insert(0, item);
    }