Пример #1
0
        public String GetCategoryName(int id)
        {
            CategoryIncomeClient ac       = new CategoryIncomeClient();
            CategoryIncome       category = ac.Find(id);

            return(category.Name);
        }
Пример #2
0
        public async Task <IActionResult> PutCategoryIncome([FromRoute] int id, [FromBody] CategoryIncome CategoryIncome)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != CategoryIncome.Id)
            {
                return(BadRequest());
            }

            _context.Entry(CategoryIncome).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryIncomeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
        public ActionResult Edit(CategoryIncome CIVM)
        {
            CategoryIncomeClient client = new CategoryIncomeClient();

            client.Edit(CIVM);
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Create(CategoryIncome CategoryIncome)
        {
            CategoryIncomeClient client = new CategoryIncomeClient();

            client.Create(CategoryIncome);
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public async Task <IActionResult> PostCategoryIncome([FromBody] CategoryIncome CategoryIncome)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CategoryIncome.Add(CategoryIncome);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoryIncome", new { id = CategoryIncome.Id }, CategoryIncome));
        }
Пример #6
0
        public ActionResult Create()
        {
            ClaimsPrincipal currentUser = User;

            var userId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            var model = new CategoryIncome
            {
                UserId = userId
            };

            return(View(model));
        }
 public bool Edit(CategoryIncome CategoryIncome)
 {
     try
     {
         HttpClient client = new HttpClient
         {
             BaseAddress = new Uri(Base_URL)
         };
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HttpResponseMessage response = client.PutAsJsonAsync("CategoryIncomes/" + CategoryIncome.Id, CategoryIncome).Result;
         return response.IsSuccessStatusCode;
     }
     catch
     {
         return false;
     }
 }