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; }
public FrmRecipesInsert(bool isInsert, int id = 0) { InitializeComponent(); _rService = new Recipes_Services(); _cService = new Categories_Services(); _iService = new Ingredients_Services(); _riService = new RecipesIngredients_Services(); }
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(); }
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)); } }
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)); } }
public async Task AddCategoryToService(Categories_Services categories_Services) { var service = db.Categories_Services.Add(categories_Services); await db.SaveChangesAsync(); }
public FrmCategories(string title) { InitializeComponent(); _service = new Categories_Services(); _title = title; }
public async Task DeleteCategoryService(Categories_Services category) { db.Categories_Services.Remove(category); await db.SaveChangesAsync(); }
public async Task UpdateCategoryToService(Categories_Services categoryToService) { db.Entry(categoryToService).State = EntityState.Modified; await db.SaveChangesAsync(); }
protected void Page_Load(object sender, EventArgs e) { _service = new Categories_Services(); this.rptCategory.DataSource = _service.GetALL(); this.rptCategory.DataBind(); }