public async Task <IActionResult> CreateSub(Subcategory subcategory)
        {
            if (ModelState.IsValid)
            {
                _offerDbContext.Subcategories.Add(subcategory);
                await _offerDbContext.SaveChangesAsync();

                SubViewModel subview = new SubViewModel();
                subview.CategoryList = await _offerDbContext.Categories.Select(a => new SelectListItem()
                {
                    Value = a.Id.ToString(),
                    Text  = a.Name
                }).ToListAsync();

                subview.Subcategories = await _offerDbContext.Subcategories.ToListAsync();

                subview.Categories = await _offerDbContext.Categories.ToListAsync();

                subview.Subcategory = await _offerDbContext.Subcategories.LastOrDefaultAsync();

                return(RedirectToAction(nameof(CreateSub)));
            }
            else
            {
                ModelState.AddModelError("", "Couldn't create");
                return(View());
            }
        }
        public async Task <IActionResult> DeleteSub(int Id)
        {
            SubViewModel subview = new SubViewModel();

            subview.Subcategory = await _offerDbContext.Subcategories.SingleOrDefaultAsync(x => x.Id == Id);

            return(View(subview));
        }
Esempio n. 3
0
 public void Commit()
 {
     if (SubViewModel != null)
     {
         SubViewModel.Commit();
     }
     _notificationAction.ActionCondition = SelectedActionCondition.Data;
     _notificationAction.Interval        = Interval;
 }
Esempio n. 4
0
        public void Update(SubViewModel vm)
        {
            Sub s = new Sub();

            s.Id     = vm.Id;
            s.Name   = vm.Name;
            s.Status = true;
            _context.Subs.Update(s);
            _context.SaveChanges();
        }
Esempio n. 5
0
            /// <summary>
            /// このインスタンスの検証を実行します。<para />
            /// 属性による検証以外で必要な検証はここで行います。
            /// </summary>
            protected override void OnValidate()
            {
                base.OnValidate();

                if (DayOfWeek == DayOfWeek.Monday)
                {
                    NotificationError(() => DayOfWeek, $"曜日には{DayOfWeek.Monday}は設定できません。");
                }

                SubViewModel.Validate();
            }
Esempio n. 6
0
        public int Add(SubViewModel s)
        {
            var p = new Sub();

            p.Name   = s.Name;
            p.Status = true;
            var a = _context.Subs.Add(p);

            _context.SaveChanges();
            return(a.Entity.Id);
        }
        public async Task <IActionResult> DeleteSub(Subcategory subcategory, int Id)
        {
            SubViewModel subview = new SubViewModel();

            subview.Subcategory = await _offerDbContext.Subcategories.SingleOrDefaultAsync(x => x.Id == Id);

            subcategory = subview.Subcategory;
            _offerDbContext.Subcategories.Remove(subcategory);
            await _offerDbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(CreateSub)));
        }
Esempio n. 8
0
        public IActionResult Category(int Id)
        {
            category_id = Id;
            SubViewModel subModel = new SubViewModel();

            subModel.Subcategories = _offerDbContext.Subcategories.Where(x => x.CategoryId == Id).ToList();
            subModel.Posts         = _offerDbContext.Posts.Where(y => y.Subcategory.CategoryId == Id).ToList();
            subModel.Companies     = _offerDbContext.Companies.ToList();
            ViewBag.Posts          = _offerDbContext.Posts.Where(u => u.Subcategory.CategoryId == category_id).ToList();
            ViewData["Category"]   = _localizer["Kateqoriyalar"];
            return(View(subModel));
        }
Esempio n. 9
0
        //from menu dropdown
        public async Task <IActionResult> MenuSub(int Id)
        {
            SubViewModel subView = new SubViewModel();

            subView.Subcategory = await _offerDbContext.Subcategories.Where(y => y.Id == Id).SingleOrDefaultAsync();

            menuCatId     = subView.Subcategory.CategoryId;
            subView.Posts = await _offerDbContext.Posts.Where(z => z.SubcategoryId == Id).ToListAsync();

            subView.Companies = await _offerDbContext.Companies.ToListAsync();

            ViewBag.subCategories = _offerDbContext.Subcategories.Where(c => c.CategoryId == menuCatId).ToList();
            ViewBag.SubPosts      = await _offerDbContext.Posts.Where(n => n.SubcategoryId == Id).ToListAsync();

            return(View("Subcategory", subView));
        }
Esempio n. 10
0
        public async Task <List <SubViewModel> > GetAll()
        {
            var listItems = await _context.Subs.Where(x => x.Status == true).OrderByDescending(x => x.Name).ToListAsync();

            List <SubViewModel> listVM = new List <SubViewModel>();

            foreach (var item in listItems)
            {
                SubViewModel vm = new SubViewModel();
                vm.Id     = item.Id;
                vm.Name   = item.Name;
                vm.Status = item.Status;
                listVM.Add(vm);
            }
            return(listVM);
        }
        public async Task <IActionResult> CreateSub()
        {
            SubViewModel subview = new SubViewModel();

            subview.Subcategories = await _offerDbContext.Subcategories.ToListAsync();

            subview.Categories = await _offerDbContext.Categories.ToListAsync();

            subview.CategoryList = await _offerDbContext.Categories.Select(a => new SelectListItem()
            {
                Value = a.Id.ToString(),
                Text  = a.Name
            }).ToListAsync();

            return(View(subview));
        }
        public async Task <IActionResult> EditSubcat(int Id)
        {
            SubViewModel subview = new SubViewModel();

            subview.Subcategory = await _offerDbContext.Subcategories.SingleOrDefaultAsync(x => x.Id == Id);

            subview.Categories = await _offerDbContext.Categories.ToListAsync();

            subview.CategoryList = await _offerDbContext.Categories.Select(a => new SelectListItem()
            {
                Value = a.Id.ToString(),
                Text  = a.Name
            }).ToListAsync();

            return(View(subview));
        }
Esempio n. 13
0
        public async Task <IActionResult> Subcategory(int Id)
        {
            subId = Id;
            SubViewModel subView = new SubViewModel();

            subView.Subcategory = await _offerDbContext.Subcategories.Where(y => y.Id == Id).SingleOrDefaultAsync();

            subView.Posts = await _offerDbContext.Posts.Where(z => z.SubcategoryId == Id).ToListAsync();

            subView.Companies = await _offerDbContext.Companies.ToListAsync();

            ViewBag.subCategories = _offerDbContext.Subcategories.Where(c => c.CategoryId == category_id).ToList();
            ViewBag.SubPosts      = await _offerDbContext.Posts.Where(n => n.SubcategoryId == Id).ToListAsync();

            ViewData["Category"] = _localizer["Kateqoriyalar"];
            return(View(subView));
        }
Esempio n. 14
0
        public SubViewModel GetById(int id)
        {
            var c = _context.Subs.Find(id);

            if (c == null)
            {
                throw new Exception("Sub isn't in data.");
            }
            SubViewModel vm = new SubViewModel();

            vm.Id     = c.Id;
            vm.Name   = c.Name;
            vm.Status = c.Status;

            vm.Status = c.Status;
            return(vm);
        }
Esempio n. 15
0
        public async Task <IActionResult> getSubCompany(int Id)
        {
            SubViewModel svmodel = new SubViewModel();

            svmodel.Subcategory = await _offerDbContext.Subcategories.Where(z => z.Id == subId).SingleOrDefaultAsync();

            svmodel.Posts = await _offerDbContext.Posts.Where(t => t.SubcategoryId == subId && t.CompanyId == Id).ToListAsync();

            svmodel.Companies = await _offerDbContext.Companies.Where(k => k.Id == Id).ToListAsync();

            ViewBag.subCategories = await _offerDbContext.Subcategories.Where(c => c.CategoryId == category_id).ToListAsync();

            ViewBag.SubPosts = await _offerDbContext.Posts.Where(n => n.SubcategoryId == subId).ToListAsync();

            ViewBag.Companies = await _offerDbContext.Companies.ToListAsync();

            return(View("Subcategory", svmodel));
        }
Esempio n. 16
0
        public async Task <IActionResult> getCompany(int Id)
        {
            SubViewModel subViewModel = new SubViewModel();

            subViewModel.Subcategories = await _offerDbContext.Subcategories.Where(x => x.CategoryId == category_id).ToListAsync();

            subViewModel.Companies = await _offerDbContext.Companies.Where(a => a.Id == Id).ToListAsync();

            subViewModel.Posts = await _offerDbContext.Posts.Where(b => b.CompanyId == Id && b.Subcategory.CategoryId == category_id).ToListAsync();

            ViewBag.subCategories = await _offerDbContext.Subcategories.Where(c => c.CategoryId == category_id).ToListAsync();

            ViewBag.Posts = await _offerDbContext.Posts.Where(u => u.Subcategory.CategoryId == category_id).ToListAsync();

            ViewBag.Companies = await _offerDbContext.Companies.ToListAsync();

            return(View("Category", subViewModel));
        }
Esempio n. 17
0
 public IActionResult SaveEntity(SubViewModel vm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     else
     {
         int id = 0;
         if (vm.Id == 0)
         {
             id = _subService.Add(vm);
         }
         else
         {
             _subService.Update(vm);
             id = vm.Id;
         }
         return(new OkObjectResult(id));
     }
 }
        public async Task <IActionResult> EditSubcat(Subcategory subcategory, int Id)
        {
            if (Id != subcategory.Id)
            {
                ModelState.AddModelError("", "Invalid Id");
                return(View());
            }

            if (ModelState.IsValid)
            {
                SubViewModel subview = new SubViewModel();
                subview.Subcategory = await _offerDbContext.Subcategories.SingleOrDefaultAsync(x => x.Id == Id);

                if (subview.Subcategory != null)
                {
                    subview.Subcategory.Name       = subcategory.Name;
                    subview.Subcategory.CategoryId = subcategory.CategoryId;
                    await _offerDbContext.SaveChangesAsync();

                    subview.CategoryList = await _offerDbContext.Categories.Select(a => new SelectListItem()
                    {
                        Value = a.Id.ToString(),
                        Text  = a.Name
                    }).ToListAsync();

                    subview.Subcategories = await _offerDbContext.Subcategories.ToListAsync();

                    subview.Categories = await _offerDbContext.Categories.ToListAsync();

                    subview.Subcategory = await _offerDbContext.Subcategories.LastOrDefaultAsync();
                }
                return(RedirectToAction(nameof(CreateSub)));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 19
0
 public SampleViewModel(SubViewModel subViewModel, Model model)
 {
     SubViewModel = subViewModel;
     Model        = model;
 }
 public MyViewModel()
 {
     _subViewModel       = new SubViewModel();
     _subViewModel.Text1 = "blabla";
 }
Esempio n. 21
0
 public SubWindow()
 {
     DataContext = new SubViewModel();
     InitializeComponent();
 }
Esempio n. 22
0
 public void Init()
 {
     Current       = new SubViewModel();
     Current.Title = "Hello World";
 }
Esempio n. 23
0
 public SampleViewModel(SubViewModel subViewModel, Model model)
 {
     SubViewModel = subViewModel;
     Model = model;
 }
Esempio n. 24
0
		public void Init()
		{
			Current = new SubViewModel();
			Current.Title = "Hello World";
		}
Esempio n. 25
0
 public MainWindowViewModel()
 {
     SubViewModel = new SubViewModel(AsInterface.ServiceContainer);
 }