Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
        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));
            }
        }
Esempio n. 5
0
        public ActionResult Edit(int id)
        {
            ClanDto clanDto = _clanClient.GetById(id);

            return(View(clanDto));
        }
Esempio n. 6
0
 public void Update(ClanDto value)
 {
     Clan clan = _clanMapper.Map<Clan>(value);
     _clanRepository.Update(clan);
 }
Esempio n. 7
0
 public void Add(ClanDto value)
 {
     Clan evidencijaDugovanja = _clanMapper.Map<Clan>(value);
     _clanRepository.Save(evidencijaDugovanja);
 }
Esempio n. 8
0
 public ActionResult Delete(ClanDto value)
 {
     _clanService.Delete(value);
     return(Ok());
 }
Esempio n. 9
0
 public ActionResult Update(ClanDto value)
 {
     _clanService.Update(value);
     return(Ok());
 }
Esempio n. 10
0
 public ActionResult Add(ClanDto value)
 {
     _clanService.Add(value);
     return(Ok());
 }