Exemple #1
0
        public Models.SellingPoint CreateSellingPoint(SellingPointDto sellingPointDto)
        {
            const string sql =
                "INSERT INTO SkiTickets.SellingPoint VALUES (@name, @location)" +
                " SELECT * FROM SkiTickets.SellingPoint WHERE id = SCOPE_IDENTITY()";

            return(TransformDaoToBusinessLogicSellingPoint(_database.QueryFirst <SellingPointDao>(sql,
                                                                                                  new { name = sellingPointDto.Name, location = sellingPointDto.Location })));
        }
Exemple #2
0
        public Models.SellingPoint UpdateSellingPoint(int id, SellingPointDto sellingPointDto)
        {
            const string sql =
                "UPDATE SkiTickets.SellingPoint SET name = @name, location = @location WHERE id = @id";

            _database.Execute(sql, new
            {
                id       = id,
                name     = sellingPointDto.Name,
                location = sellingPointDto.Location,
            });

            return(GetSellingPointById(id));
        }
 public ActionResult <Models.Person> CreatePerson([FromBody] SellingPointDto sellingPointDto)
 {
     try
     {
         return(Created("https://localhost:5001/SellingPoint", new OkResponse <Models.SellingPoint>(_sellingPoint.CreateSellingPoint(sellingPointDto))));
     }
     catch (SellingPointBadRequestException e)
     {
         return(BadRequest(new ErrorResponse(e.Message, new List <string>()
         {
             "sellingPoint"
         })));
     }
     catch (Exception e)
     {
         return(BadRequest(new ErrorResponse(e.Message, new List <string>()
         {
             "sellingPoint"
         })));
     }
 }
 public ActionResult <Models.SellingPoint> UpdateSellingPoint(int sellingPointId, SellingPointDto sellingPointDto)
 {
     try
     {
         return(Ok(new OkResponse <Models.SellingPoint>(_sellingPoint.UpdateSellingPoint(sellingPointId, sellingPointDto))));
     }
     catch (SellingPointNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (SellingPointBadRequestException e)
     {
         return(BadRequest(new ErrorResponse(e.Message, new List <string>()
         {
             "sellingPoint", "sellingPointId"
         })));
     }
     catch (Exception e)
     {
         return(BadRequest(new ErrorResponse(e.Message, new List <string>()
         {
             "sellingPoint", "sellingPointId"
         })));
     }
 }