public AuthorityIngredientDecorator(IIngredientController ingredientController, string role) { IngredientController = ingredientController; Role = role; AuthorizedUsers = new Dictionary <string, List <string> >(); AuthorizedUsers["Delete"] = new List <String>() { "Director" }; AuthorizedUsers["Edit"] = new List <String>() { "Director" }; AuthorizedUsers["Get"] = new List <String>() { "Director", "Doctor" }; AuthorizedUsers["GetAll"] = new List <String>() { "Director", "Doctor" }; AuthorizedUsers["Save"] = new List <String>() { "Director" }; }
private void OnDelete(IngredientEditDTO ingredientEditDTO, IngredientEditViewModel viewModel) { using (IIngredientController controller = factory.CreateIngredientController()) { ControllerMessage controllerMessage = controller.Delete(ingredientEditDTO.OldName); if (controllerMessage.IsSuccess) { Notify(); viewModel.Clear(); } else { MessageBox.Show(controllerMessage.Message); } } }
private void OnSave(IngredientEditDTO ingredientEditDTO) { using (IIngredientController controller = factory.CreateIngredientController()) { ControllerMessage controllerMessage = controller.Update(ingredientEditDTO); if (controllerMessage.IsSuccess) { ingredientEditDTO.OldName = ingredientEditDTO.NewName; Notify(); } else { MessageBox.Show(controllerMessage.Message); } } }
private void OnAdd(string ingredientName, IngredientAddViewModel viewModel) { using (IIngredientController controller = factory.CreateIngredientController()) { ControllerMessage controllerMessage = controller.Add(ingredientName); if (controllerMessage.IsSuccess) { viewModel.Name = String.Empty; Notify(); } else { MessageBox.Show(controllerMessage.Message); } } }
public void Update() { Ingredients.Clear(); using (IIngredientController controller = factory.CreateIngredientController()) { DataControllerMessage <IEnumerable <IngredientDisplayDTO> > controllerMessage = controller.GetAll(); if (controllerMessage.IsSuccess) { foreach (IngredientDisplayDTO ingredient in controllerMessage.Data) { Ingredients.Add(ingredient); } } } }
public void ChangeIngredient(string ingredientName) { using (IIngredientController controller = factory.CreateIngredientController()) { DataControllerMessage <IngredientEditDTO> controllerMessage = controller.Get(ingredientName); if (controllerMessage.IsSuccess) { this.ingredient = controllerMessage.Data; this.Stocks.Clear(); foreach (int stockNo in ingredient.StocksAvailable) { this.Stocks.Add(stockNo); } RaisePropertyChangedEvent("Name"); } } }