Ejemplo n.º 1
0
        public PartialViewResult Index()
        {
            HeaderViewModel model = new HeaderViewModel();

            List <MainMenuDto> items = new List <MainMenuDto>();

            model.MainMenus = items;

            MainMenuDto item1 = new MainMenuDto {
                MenuText = "Content", NavigateUrl = "Folder?subsiteid=0"
            };
            MainMenuDto item2 = new MainMenuDto {
                MenuText = "Document", NavigateUrl = "Document"
            };
            MainMenuDto item3 = new MainMenuDto {
                MenuText = "Setting", NavigateUrl = "Setting"
            };
            MainMenuDto item4 = new MainMenuDto {
                MenuText = "Subsite", NavigateUrl = "Subsite"
            };
            MainMenuDto item5 = new MainMenuDto {
                MenuText = "Collection", NavigateUrl = "Collection"
            };

            items.Add(item1);
            items.Add(item2);
            items.Add(item3);
            items.Add(item4);
            items.Add(item5);

            return(PartialView(model));
        }
Ejemplo n.º 2
0
        internal IFacadeUpdateResult <MainMenuData> SaveMainMenu(MainMenuDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <MainMenuData> result = new FacadeUpdateResult <MainMenuData>();
            IMainMenuService service  = UnitOfWork.GetService <IMainMenuService>();
            MainMenu         instance = RetrieveOrNew <MainMenuData, MainMenu, IMainMenuService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.Name        = dto.Name;
                instance.MenuText    = dto.MenuText;
                instance.Tooltip     = dto.Tooltip;
                instance.NavigateUrl = dto.NavigateUrl;
                instance.ImageUrl    = dto.ImageUrl;
                instance.Sort        = dto.Sort;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <MainMenuData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> UpdateCuisine([FromBody] MainMenuDto value)
        {
            var response = new SingleModelResponse <MainMenuDto>() as ISingleModelResponse <MainMenuDto>;

            try
            {
                var entity = await _mainMenuRepository
                             .UpdateAsync(value.ToEntity());

                if (entity != null)
                {
                    response.Model   = entity.ToViewModel();
                    response.Message = "The record was updated successfully";
                }
                else
                {
                    response.Model   = null;
                    response.Message = "The record was not updated";
                }
            }
            catch (Exception ex)
            {
                response.IsError      = true;
                response.ErrorMessage = ex.ToString();
            }
            return(response.ToHttpResponse());
        }
Ejemplo n.º 4
0
        public IEnumerable <MainMenuDto> GetFooterMenus()
        {
            List <MainMenuDto> items = new List <MainMenuDto>();

            MainMenuDto item1 = new MainMenuDto {
                NavigateUrl = "recipe", MenuText = "Recipes"
            };

            items.Add(item1);
            SetSubMenu(item1);

            MainMenuDto item2 = new MainMenuDto {
                NavigateUrl = "article", MenuText = "Articles"
            };

            items.Add(item2);

            MainMenuDto item3 = new MainMenuDto {
                NavigateUrl = "gallery", MenuText = "Photos"
            };

            items.Add(item3);

            MainMenuDto item4 = new MainMenuDto {
                NavigateUrl = "video", MenuText = "Videos"
            };

            items.Add(item4);

            return(items);
        }
Ejemplo n.º 5
0
 private void RetrieveData()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
     {
         MainMenuFacade facade   = new MainMenuFacade(uow);
         MainMenuDto    instance = facade.RetrieveOrNewMainMenu(InstanceId);
         CurrentInstance         = instance;
         ucIEdit.CurrentInstance = instance;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Convert view model to db entity
 /// </summary>
 /// <param name="viewModel"></param>
 /// <returns></returns>
 public static MainMenu ToEntity(this MainMenuDto viewModel)
 {
     return(viewModel == null ? null : new MainMenu
     {
         Id = viewModel.Id,
         Name = viewModel.Name,
         Description = viewModel.Description,
         ImagePath = viewModel.ImagePath,
         Guid = viewModel.Guid,
         IsActive = viewModel.IsActive
     });
 }
Ejemplo n.º 7
0
 public MenuItemViewModel(MainMenuDto item, LanguageDto currentLanguage)
 {
     if (item.MainMenuLanguagesDic != null && item.MainMenuLanguagesDic.ContainsKey(currentLanguage.Id))
     {
         MenuText = item.MainMenuLanguagesDic[currentLanguage.Id].MenuText;
     }
     else
     {
         MenuText = item.MenuText;
     }
     NavigateUrl = item.NavigateUrl;
     Tooltip     = item.Tooltip;
 }
Ejemplo n.º 8
0
        private void SetSubMenu(MainMenuDto item)
        {
            List <MainMenuDto> subItems = new List <MainMenuDto>();

            item.SubMenus = subItems;
            for (int j = 1; j <= 7; j++)
            {
                MainMenuDto subItem = new MainMenuDto {
                    NavigateUrl = string.Format("{0}/category/category{1}", item.NavigateUrl, j), MenuText = string.Format("Category{0}", j)
                };
                subItems.Add(subItem);
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> CreateCuisine([FromBody] MainMenuDto model)
        {
            var response = new SingleModelResponse <MainMenuDto>() as ISingleModelResponse <MainMenuDto>;

            //*** check for model is valid or not if invalid returning bad request response
            if (model == null)
            {
                response.IsError      = true;
                response.ErrorMessage = "Invalid request";
                return(new ObjectResult(response)
                {
                    StatusCode = (Int32)HttpStatusCode.BadRequest
                });
            }

            // Check for duplicate Canonical text for the same name.
            var isDuplicate = await _mainMenuRepository.IsExistsAsync(x => x.Name.Equals(model.Name));

            if (isDuplicate)
            {
                // It's a duplicate.  Return an HTTP 409 Conflict error to let the client know.
                var original = await _mainMenuRepository
                               .GetAsync(new MainMenu { Id = model.Id });

                response.IsError      = true;
                response.ErrorMessage = "Record already exits in the system";
                response.Model        = original.ToViewModel();

                return(new ObjectResult(response)
                {
                    StatusCode = (Int32)HttpStatusCode.Conflict
                });
            }

            try
            {
                model.Guid = Guid.NewGuid();
                var entity = await _mainMenuRepository
                             .InsertAsync(model.ToEntity());

                response.Model   = entity.ToViewModel();
                response.Message = "The data was saved successfully";
            }
            catch (Exception ex)
            {
                response.IsError      = true;
                response.ErrorMessage = ex.ToString();
            }

            return(CreatedAtRoute("GetCuisines", new { id = response.Model.Id }, response.Model));
        }
Ejemplo n.º 10
0
        public IFacadeUpdateResult <MainMenuData> SaveMainMenu(MainMenuDto dto)
        {
            UnitOfWork.BeginTransaction();
            IFacadeUpdateResult <MainMenuData> result = MainMenuSystem.SaveMainMenu(dto);

            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }
            return(result);
        }
Ejemplo n.º 11
0
        protected void ucIList_InstanceRowSaving(object sender, InstanceRowSavingEventArgs e)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                MainMenuDto    project = e.Instance as MainMenuDto;
                MainMenuFacade facade  = new MainMenuFacade(uow);
                IFacadeUpdateResult <MainMenuData> result = facade.SaveMainMenu(project);
                e.IsSuccessful = result.IsSuccessful;

                if (result.IsSuccessful)
                {
                    // Refresh whole list
                    CurrentInstances = facade.RetrieveAllMainMenu();
                    // Refresh global cache
                }
                else
                {
                    // Deal with Update result
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
        }
Ejemplo n.º 12
0
        protected void ucIEdit_InstanceSaving(object sender, InstanceSavingEventArgs e)
        {
            MainMenuDto instance = e.Instance as MainMenuDto;

            if (instance != null)
            {
                using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
                {
                    MainMenuFacade facade = new MainMenuFacade(uow);
                    IFacadeUpdateResult <MainMenuData> result = facade.SaveMainMenu(instance);
                    e.IsSuccessful = result.IsSuccessful;
                    if (result.IsSuccessful)
                    {
                        // Refresh Instance
                        CurrentInstance = result.ToDto <MainMenuDto>(new MainMenuConverter());
                    }
                    else
                    {
                        // Deal with Update result
                        ProcUpdateResult(result.ValidationResult, result.Exception);
                    }
                }
            }
        }