Пример #1
0
        public async Task <Categories_Services> AddCategoryToService(Categories_Services category)
        {
            var result = db.Categories_Services.Add(category);
            await db.SaveChangesAsync();

            return(result);
        }
        public async Task <object> EditCategoryToService(Categories_Services request)
        {
            if (!ModelState.IsValid)
            {
                return(JsonResults.Error(400, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage.ToString()));
            }

            try
            {
                var categoryToService = await _categoryService.GetCategoryService(request.Id);

                if (categoryToService == null)
                {
                    return(JsonResults.Error(404, "It`s category not found"));
                }

                categoryToService.IdCategories = request.IdCategories;

                await _categoryService.UpdateCategoryToService(categoryToService);

                return(JsonResults.Success());
            }
            catch (Exception ex)
            {
                return(JsonResults.Error(400, ex.Message));
            }
        }
 public FrmCategories_InsertUpdate(bool isInsert, int id = 0)
 {
     InitializeComponent();
     _service  = new Categories_Services();
     _isInsert = isInsert;
     _id       = id;
 }
Пример #4
0
 public FrmRecipesInsert(bool isInsert, int id = 0)
 {
     InitializeComponent();
     _rService  = new Recipes_Services();
     _cService  = new Categories_Services();
     _iService  = new Ingredients_Services();
     _riService = new RecipesIngredients_Services();
 }
Пример #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _rService  = new Recipes_Services();
     _cService  = new Categories_Services();
     _iService  = new Ingredients_Services();
     _riService = new RecipesIngredients_Services();
     _uService  = new Users_Services();
     FillComboBoxes();
     CreateDataTable();
 }
Пример #6
0
        public async Task <ActionResult> Create([Bind(Include = "IdCategories,IdServices")] Categories_Services categories_Services)
        {
            try
            {
                await(Data.URL + "Categories/AddCategoryToService").WithHeader("Authorization", Data.Token).PostJsonAsync(categories_Services);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(new HttpStatusCodeResult(HttpStatusCode.RequestTimeout));
            }
        }
Пример #7
0
        public async Task <object> AddCategoryToService(Categories_Services request)
        {
            try
            {
                var isCategoryContain = await _servicesService.CheckCategoryInServices((int)request.IdCategories, (int)request.IdServices);

                if (isCategoryContain)
                {
                    return(JsonResults.Error(406, "This service already has this category."));
                }

                await _servicesService.AddCategoryToService(request);

                return(JsonResults.Success());
            }
            catch (Exception ex)
            {
                return(JsonResults.Error(400, ex.Message));
            }
        }
        public async Task <object> AddCategoryToService(Categories_Services request)
        {
            if (!ModelState.IsValid)
            {
                return(JsonResults.Error(400, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage.ToString()));
            }

            try
            {
                var model = new Categories_Services
                {
                    IdCategories = request.IdCategories,
                    IdServices   = request.IdServices
                };

                await _categoryService.AddCategoryToService(model);

                return(JsonResults.Success());
            }
            catch (Exception ex)
            {
                return(JsonResults.Error(400, ex.Message));
            }
        }
Пример #9
0
 public async Task AddCategoryToService(Categories_Services categories_Services)
 {
     var service = db.Categories_Services.Add(categories_Services);
     await db.SaveChangesAsync();
 }
Пример #10
0
 public FrmCategories(string title)
 {
     InitializeComponent();
     _service = new Categories_Services();
     _title   = title;
 }
Пример #11
0
 public async Task DeleteCategoryService(Categories_Services category)
 {
     db.Categories_Services.Remove(category);
     await db.SaveChangesAsync();
 }
Пример #12
0
 public async Task UpdateCategoryToService(Categories_Services categoryToService)
 {
     db.Entry(categoryToService).State = EntityState.Modified;
     await db.SaveChangesAsync();
 }
Пример #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _service = new Categories_Services();
     this.rptCategory.DataSource = _service.GetALL();
     this.rptCategory.DataBind();
 }