Example #1
0
        public IHttpActionResult PostSommerhusTable(SommerhusTable sommerhusTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SommerhusTables.Add(sommerhusTable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SommerhusTableExists(sommerhusTable.sommerhusNavn))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = sommerhusTable.sommerhusNavn }, sommerhusTable));
        }
Example #2
0
        public IHttpActionResult PutSommerhusTable(string id, SommerhusTable sommerhusTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sommerhusTable.sommerhusNavn)
            {
                return(BadRequest());
            }

            db.Entry(sommerhusTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SommerhusTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult GetSommerhusTable(string id)
        {
            SommerhusTable sommerhusTable = db.SommerhusTables.Find(id);

            if (sommerhusTable == null)
            {
                return(NotFound());
            }

            return(Ok(sommerhusTable));
        }
Example #4
0
        public IHttpActionResult DeleteSommerhusTable(string id)
        {
            SommerhusTable sommerhusTable = db.SommerhusTables.Find(id);

            if (sommerhusTable == null)
            {
                return(NotFound());
            }

            db.SommerhusTables.Remove(sommerhusTable);
            db.SaveChanges();

            return(Ok(sommerhusTable));
        }
Example #5
0
        public override SummerHouse CreateDomainObject(SommerhusTable tObj)
        {
            SummerHouse summerhouse = new SummerHouse()

            {
                StreetName   = tObj.vejNavn,
                StreetNr     = tObj.vejNummer,
                ZipCode      = tObj.postNummer,
                City         = tObj.by,
                Municipality = tObj.kommune,
                NickName     = tObj.sommerhusNavn,
                PricePrNight = tObj.prisPrNat
            };


            return(summerhouse);
        }