Example #1
0
        public ActionResult Index1()
        {
            try
            {
                var user       = userBusinessLogic.GetUsers().Result.FirstOrDefault();
                var categories = categoryBusinessLogic.GetAllCategories().Result;

                BeSafeModels.HomeModel homeModel = new BeSafeModels.HomeModel();
                //var irem = mapUserEntityToModel.ConvertObject(user);
                homeModel.User       = mapUserEntityToModel.ConvertObject(user);
                homeModel.categories = mapCategoryEntityToModel.ConvertObjectCollection(categories);
                //foreach (var item in categories)
                //{
                //    homeModel.categories.Add(
                //        new BeSafeModels.Category()
                //        {
                //            CategoryId=item.CategoryId,
                //            CategoryName=item.CategoryName,
                //            ParentCategoryId=item.ParentCategoryId,
                //            Parent= mapCategoryEntityToModel.ConvertObject(item.Parent),
                //            Children= mapCategoryEntityToModel.ConvertObjectCollection(item.Children),
                //            MasterItems=mapMasterItemEntityToModel.ConvertObjectCollection(item.MasterItems),
                //            Remarks=item.Remarks
                //        }
                //        );
                //}

                return(View(homeModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 public ActionResult Index()
 {
     try
     {
         var user       = userBusinessLogic.GetUsers().Result.FirstOrDefault();
         var categories = categoryBusinessLogic.GetAllCategories().Result;
         BeSafeModels.HomeModel homeModel = new BeSafeModels.HomeModel();
         homeModel.User       = mapUserEntityToModel.ConvertObject(user);
         homeModel.categories = mapCategoryEntityToModel.ConvertObjectCollection(categories);
         return(View(homeModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
        public IEnumerable <Models.Film> GetFilms()
        {
            var filmList  = _service.GetAll();
            var mFilmList = mapEntityToModel.ConvertObjectCollection(filmList);

            return(mFilmList);
        }
Example #4
0
 public async Task <IActionResult> AddOrEditCategoryItem(long ItemId, [Bind("ItemId,CreatedDate,CategoryId,ItemType,Name,Description,ItemLink,UploadFile")] BeSafeModels.MasterItemsSet masterItemsSet)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (ItemId == 0)
             {
                 var masterItem = mapMasterItemModelToEntity.ConvertObject(masterItemsSet);
                 if (masterItemsSet.UploadFile != null)
                 {
                     var uniqueFileName = Util.GetUniqueFileName(masterItemsSet.UploadFile.FileName);
                     var uploads        = Path.Combine(hostingEnvironment.WebRootPath, "UploadedMasterItem");
                     var filePath       = Path.Combine(uploads, uniqueFileName);
                     masterItemsSet.UploadFile.CopyTo(new FileStream(filePath, FileMode.Create));
                     masterItem.ItemLink = uniqueFileName;
                 }
                 //masterItem.CreatedDate = DateTime.Now;
                 masterItem.CreatedDate = masterItemsSet.CreatedDate; //he dont accept this
                 //   masterItem.CreatedDate.ToString(string.Format("{0:dd/MM/yyyy}"));
                 await masterItemBusinessLogic.AddMasterItem(masterItem);
             }
             else
             {
                 //var masterItem = await masterItemBusinessLogic.GetMasterItemById(ItemId);
                 //masterItem. = category.CategoryName;
                 //masterItem.Remarks = category.Remarks;
                 var masterItem = mapMasterItemModelToEntity.ConvertObject(masterItemsSet);
                 //var CategoryEntity = mapCategoryModelToEntity.ConvertObject(category);
                 await masterItemBusinessLogic.UpdateMasterItem(masterItem);
             }
         }
         catch (Exception)
         {
             throw;
         }
         var masterItems     = masterItemBusinessLogic.GetMasterItemsByCategoryId(masterItemsSet.CategoryId).Result;
         var masterItemsSets = mapMasterItemEntityToModel.ConvertObjectCollection(masterItems);
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAllMasterItem", masterItemsSets) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEditCategoryItem", masterItemsSet) }));
 }