public IHttpActionResult PostMemberByClan(int gameid, int clanid, [FromBody] MemberDto memberDto) { 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 member = Mapper.Map <MemberDto, Member>(memberDto); member.clanId = clanid; _context.Members.Add(member); _context.SaveChanges(); memberDto.id = member.id; Response.Status = ConstantValues.ResponseStatus.OK; Response.Member = memberDto; return(Created(new Uri(Request.RequestUri + "/" + memberDto.id), Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }
public IHttpActionResult PostReservationByGamer(int gamerid, [FromBody] ReservationDto reservationdto) { 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 reservation = Mapper.Map <ReservationDto, Reservation>(reservationdto); reservation.gamerId = gamerid; _context.Reservations.Add(reservation); _context.SaveChanges(); reservationdto.id = reservation.id; reservationdto.gamerId = gamerid; Response.Status = ConstantValues.ResponseStatus.OK; Response.Reservation = reservationdto; return(Created(new Uri(Request.RequestUri + "/" + reservationdto.id), Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }
public IHttpActionResult CreateGame(GameDto gameDto) { 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 game = Mapper.Map <GameDto, Game>(gameDto); _context.Games.Add(game); _context.SaveChanges(); gameDto.id = game.id; Response.Status = ConstantValues.ResponseStatus.OK; Response.Game = gameDto; return(Created(new Uri(Request.RequestUri + "/" + game.id), Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }
public IHttpActionResult UpdateReservationByLanCenter(int lancenterid, int reservationid, [FromBody] ReservationDto reservationdto) { EntityName = "Reservation"; 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 reservation = _context.Reservations.SingleOrDefault(r => r.id == reservationid); if (reservation == null) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = string.Format(ConstantValues.ErrorMessage.NOT_FOUND, EntityName, reservationid); return(Content(HttpStatusCode.NotFound, Response)); } reservationdto.lanCenterId = lancenterid; Mapper.Map(reservationdto, reservation); _context.SaveChanges(); reservationdto.id = reservation.id; Response.Status = ConstantValues.ResponseStatus.OK; Response.Reservation = reservationdto; return(Ok(Response)); } catch (Exception e) { Response.Status = ConstantValues.ResponseStatus.ERROR; Response.Message = ConstantValues.ErrorMessage.INTERNAL_SERVER_ERROR; return(Content(HttpStatusCode.InternalServerError, Response)); } }