public ActionResult AddNew(ServiceCategoryViewModel serviceCategoryViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ServiceCategoryRepository ServiceCategoryRepository = new ServiceCategoryRepository(new AutoSolutionContext());
                    bool IsExist = ServiceCategoryRepository.isExist(serviceCategoryViewModel.ServiceCategoryName);
                    if (!IsExist)
                    {
                        ServiceCategory serviceCategory = new ServiceCategory();
                        serviceCategory.ServiceCategoryName = serviceCategoryViewModel.ServiceCategoryName;
                        serviceCategory.ServiceCategoryCode = serviceCategoryViewModel.ServiceCategoryCode;
                        serviceCategory.Description         = serviceCategoryViewModel.Description;



                        _unitOfWork.ServiceCategory.Add(serviceCategory);
                        _unitOfWork.Complete();
                        _unitOfWork.Dispose();
                        return(RedirectToAction("GetServiceCategory"));
                    }
                    else
                    {
                        return(RedirectToAction("GetServiceCategory"));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(View());
        }
Пример #2
0
        public UnitOfWork(ApplicationDbContext context)
        {
            _context       = context;
            ProductDetails = new ReservationDetailsRepository(_context);
            Products       = new ProductRepository(_context);

            ProductCategories = new ProductCategoryRepository(_context);

            Services = new ServiceRepository(_context);

            ServiceCategories = new ServiceCategoryRepository(_context);

            Departments = new DepartmentRepository(_context);

            Menus = new MenuRepository(_context);

            SubMenus = new SubMenuRepository(_context);

            OurTeams = new OurTeamRepository(_context);

            Designations = new DesignationRepository(_context);

            Faq = new FaqRepository(_context);

            Client = new ClientRepository(_context);

            Blogs = new BlogRepository(_context);

            ContactUs = new ContactUsRepository(_context);

            Companies = new CompanyRepository(_context);

            Banner = new BannerRepository(_context);

            ChooseUs = new WhyChooseUsRepository(_context);

            ClientProducts = new ClientProductRepository(_context);

            AboutUs = new AboutUsRepository(_context);

            HostingPlan = new HostingPlanRepository(_context);

            CustomerReview = new CustomerReviewRepository(_context);

            Career = new CareerRepository(_context);

            Job = new JobRepository(_context);

            Softwares = new SoftwareRepository(_context);

            SoftwareCategories = new SoftwareCategoriesRepository(_context);

            Features = new FeaturesRepository(_context);

            BlogComment = new BlogCommentRepository(_context);

            QueryHelper = new QueryHelper();
        }
        public IHttpActionResult GetServiceCategories()
        {
            List <IServiceCategory> categories = null;

            try
            {
                using (AppDBContext context = new AppDBContext())
                {
                    categories = new ServiceCategoryRepository(context).GetAllRoot();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(typeof(AroundMeController), ex.Message + ex.StackTrace, LogType.ERROR);
                return(InternalServerError(ex));
            }
            return(Ok(categories));
        }
 public ServiceCategoryManager()
 {
     _IServiceCategoryRepository = new ServiceCategoryRepository();
 }