Ejemplo n.º 1
0
        public DataControllerMessage <CategoryEditDTO> Get(CategoryDisplayDTO categoryDisplayDTO)
        {
            string          message = String.Empty;
            bool            success = true;
            CategoryEditDTO data    = null;

            try
            {
                CategoryEntity categoryEntity = unitOfWork.Categories.Get(categoryDisplayDTO.Name);
                data = new CategoryEditDTO
                {
                    NewName = categoryEntity.Name,
                    OldName = categoryEntity.Name
                };

                foreach (DishEntity dishEntity in categoryEntity.Dishes)
                {
                    data.Dishes.Add(new DishDisplayDTO
                    {
                        CategoryName = categoryEntity.Name,
                        Name         = dishEntity.Name,
                        Price        = dishEntity.Price
                    });
                }
            }
            catch (Exception ex)
            {
                success = false;
                message = ExceptionMessageBuilder.BuildMessage(ex);
            }

            return(new DataControllerMessage <CategoryEditDTO>(success, message, data));
        }
Ejemplo n.º 2
0
        private void RaiseCategorySelectedEvent(CategoryDisplayDTO category)
        {
            var handler = CategorySelected;

            if (handler != null)
            {
                GenericEventArgs <CategoryDisplayDTO> e = new GenericEventArgs <CategoryDisplayDTO>(category);
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
 private void OnSelect(CategoryDisplayDTO categoryDisplayDTO)
 {
     using (ICategoryController controller = factory.CreateCategoryController())
     {
         DataControllerMessage <CategoryEditDTO> controllerMessage = controller.Get(categoryDisplayDTO);
         if (controllerMessage.IsSuccess)
         {
             DisplayCategory(controllerMessage.Data);
         }
         else
         {
             MessageBox.Show(controllerMessage.Message);
         }
     }
 }