public async Task <IActionResult> PutPortfolioCategory(Guid id, PortfolioCategory portfolioCategory) { if (portfolioCategory == null || id != portfolioCategory.PortfolioCategoryId) { return(BadRequest()); } _context.Entry(portfolioCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync().ConfigureAwait(true); } catch (DbUpdateConcurrencyException) { if (!PortfolioCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] PortfolioCategory portfolioCategory) { if (id != portfolioCategory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(portfolioCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PortfolioCategoryExists(portfolioCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(portfolioCategory)); }
public async Task <bool> UpdatePortfolioCategory(PortfolioCategory portfolioCategory) { string Token = await _localStorageService.GetItemAsync <string>("Token"); if (portfolioCategory.PortfolioCategoryId == Guid.Empty || string.IsNullOrEmpty(Token)) { return(false); } _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); var json = JsonConvert.SerializeObject(portfolioCategory); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); //HTTP Put var responseTask = _httpClient.PutAsync(_appSettings.BaseAPIUri + "/PortfolioCategories/" + portfolioCategory.PortfolioCategoryId, stringContent); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { return(true); } return(false); }
public async Task <Guid> AddPortfolioCategory(PortfolioCategory portfolioCategory) { string Token = await _localStorageService.GetItemAsync <string>("Token"); if (string.IsNullOrEmpty(Token)) { return(new Guid()); } _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); var json = JsonConvert.SerializeObject(portfolioCategory); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); //HTTP Post var responseTask = _httpClient.PostAsync(_appSettings.BaseAPIUri + "/PortfolioCategories", stringContent); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var responseString = result.Content.ReadAsStringAsync(); var resObject = JsonConvert.DeserializeObject <PortfolioCategory>(responseString.Result); return(resObject.PortfolioCategoryId); } return(new Guid()); }
public async Task <bool> RemovePortfolioCategory(PortfolioCategory portfolioCategory) { string Token = await _localStorageService.GetItemAsync <string>("Token"); if (portfolioCategory.PortfolioCategoryId == Guid.Empty || string.IsNullOrEmpty(Token)) { return(false); } _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); //HTTP Delete var responseTask = _httpClient.DeleteAsync(_appSettings.BaseAPIUri + "/PortfolioCategories/" + portfolioCategory.PortfolioCategoryId); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { return(true); } return(false); }
public ActionResult Create(PortfolioCategoryModel model) { if (ModelState.IsValid) { var portfolioCategory = new PortfolioCategory { Name = model.Name, IsActive = model.IsActive }; var result = portfolioCategoryService.Insert(portfolioCategory); if (result) { this.NotifySuccess("Successfully saved."); } else { this.NotifyError("Item can not saved!"); } var urlRecord = new UrlRecord { EntityId = portfolioCategory.Id, EntityName = nameof(PortfolioCategory), Slug = model.Name.ToUrlSlug() }; urlService.Save(urlRecord); return(RedirectToAction("Edit", new { Id = portfolioCategory.Id })); } return(View(model)); }
public async Task <IActionResult> Create([Bind("Id,Name")] PortfolioCategory portfolioCategory) { if (ModelState.IsValid) { _context.Add(portfolioCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(portfolioCategory)); }
public async Task <ActionResult <PortfolioCategory> > PostPortfolioCategory(PortfolioCategory portfolioCategory) { if (portfolioCategory == null) { return(BadRequest()); } _context.PortfolioCategories.Add(portfolioCategory); await _context.SaveChangesAsync().ConfigureAwait(true); return(CreatedAtAction("GetPortfolioCategory", new { id = portfolioCategory.PortfolioCategoryId }, portfolioCategory)); }
public bool Delete(PortfolioCategory category) { return(categoryRepository.Delete(category)); }
public bool Update(PortfolioCategory category) { return(categoryRepository.Update(category)); }
public bool Insert(PortfolioCategory category) { return(categoryRepository.Insert(category)); }