public IHttpActionResult PostClansByGame(int id, [FromBody] ClanDto clanDto) { dynamic Response = new ExpandoObject(); try { if (!ModelState.IsValid) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.BAD_REQUEST; return(Content(HttpStatusCode.BadRequest, Response)); } var clan = Mapper.Map <ClanDto, Clan>(clanDto); clan.gameId = id; _context.Clans.Add(clan); _context.SaveChanges(); clanDto.id = clan.id; Response.Status = ConstantValues.ResponseStatus.OK; Response.Clan = clanDto; return(Created(new Uri(Request.RequestUri + "/" + clanDto.id), Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }
public void DeleteAsync(ClanDto value) { HttpClient httpClient = GetHttpClient(); UrlBuilder urlBuilder = new UrlBuilder(this.ApiSettings); HttpContent content = new StringContent(JsonConvert.SerializeObject(value), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = httpClient.PostAsync(ControllerName + "/delete", content).Result; }
public ActionResult Edit(ClanDto value) { try { if (ModelState.IsValid) { _clanClient.UpdateAsync(value); return(RedirectToAction(nameof(Index))); } } catch (Exception ex) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Nije moguce sacuvati promene. " + "Pokusaj ponovo, ako se problem nastavi " + "kontaktiraj administratora."); } return(View(value)); }
public IHttpActionResult UpdateClanByGame(int id, int clanid, [FromBody] ClanDto clanDto) { EntityName = "Clan"; dynamic Response = new ExpandoObject(); try { if (!ModelState.IsValid) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.BAD_REQUEST; return(Content(HttpStatusCode.BadRequest, Response)); } var clan = _context.Clans.SingleOrDefault(c => c.id == clanid); if (clan == null) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = string.Format(ConstantValues.ErrorMessage.NOT_FOUND, EntityName, clanid); return(Content(HttpStatusCode.NotFound, Response)); } Mapper.Map(clanDto, clan); _context.SaveChanges(); clanDto.id = clan.id; Response.Status = ConstantValues.ResponseStatus.OK; Response.Clan = clanDto; return(Ok(Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }
public ActionResult Edit(int id) { ClanDto clanDto = _clanClient.GetById(id); return(View(clanDto)); }
public void Update(ClanDto value) { Clan clan = _clanMapper.Map<Clan>(value); _clanRepository.Update(clan); }
public void Add(ClanDto value) { Clan evidencijaDugovanja = _clanMapper.Map<Clan>(value); _clanRepository.Save(evidencijaDugovanja); }
public ActionResult Delete(ClanDto value) { _clanService.Delete(value); return(Ok()); }
public ActionResult Update(ClanDto value) { _clanService.Update(value); return(Ok()); }
public ActionResult Add(ClanDto value) { _clanService.Add(value); return(Ok()); }