public async Task<IHttpActionResult> PutPetKind(int id, PetKind petKind)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != petKind.PetKindNo)
            {
                return BadRequest();
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PetKindExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Esempio n. 2
0
 public Pet(string name, PetKind kind, char sex, DateTimeOffset dateOfBirth)
 {
     Name        = name;
     Kind        = kind;
     Sex         = sex;
     DateOfBirth = dateOfBirth;
 }
Esempio n. 3
0
 public Pet(string name, PetKind kind, char sex, DateTimeOffset dateofbirth, string birthplace)
 {
     Name        = name;
     Kind        = kind;
     Sex         = sex;
     DateOfBirth = dateofbirth;
     _birthPlace = birthplace;
 }
        public async Task<IHttpActionResult> GetPetKind(int id)
        {
            PetKind petKind = await db.PetKinds.FindAsync(id);
            if (petKind == null)
            {
                return NotFound();
            }

            return Ok(petKind);
        }
        public async Task<IHttpActionResult> PostPetKind(PetKind petKind)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.PetKinds.Add(petKind);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = petKind.PetKindNo }, petKind);
        }
Esempio n. 6
0
        public ActionResult ReadAwesomeEnum([FromForm] PetKind pet)
        {
            if (!ModelState.IsValid)
            {
                return(Content("Invalid Yo!"));
            }

            return
                (pet < PetKind.Dog || pet > PetKind.Fish ?
                 Content("Everything is fine... Wait, what?") :
                 Content("Everything is fine."));
        }
        public Pet Pet(PetKind type)
        {
            if (type == PetKind.Dog)
            {
                return(new Dog {
                    Name = "Eli", Barks = true
                });
            }

            return(new Cat {
                Name = "Biscuit", Meows = true
            });
        }
        public async Task<IHttpActionResult> DeletePetKind(int id)
        {
            PetKind petKind = await db.PetKinds.FindAsync(id);
            if (petKind == null)
            {
                return NotFound();
            }

            db.PetKinds.Remove(petKind);
            await db.SaveChangesAsync();

            return Ok(petKind);
        }
        public async Task<IHttpActionResult> GetPetKind(string petCategory, string petCode)
        {
            PetterResultType<PetKind> petterResultType = new PetterResultType<PetKind>();
            List<PetKind> petKinds = new List<PetKind>();

            PetKind petKind = await db.PetKinds.Where(p => p.PetCategory == petCategory & p.PetCode == petCode).SingleOrDefaultAsync();

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

            petKinds.Add(petKind);
            petterResultType.IsSuccessful = true;
            petterResultType.JsonDataSet = petKinds;

            return Ok(petterResultType);
        }
Esempio n. 10
0
 public Pet(
     Guid id,
     string name,
     DateTimeOffset birthday,
     Sex sex,
     PetKind kind,
     string description,
     string image,
     Func <Owner> getOwner)
 {
     this.Id          = id;
     this.Name        = name;
     this.Birthday    = birthday;
     this.Sex         = sex;
     this.Kind        = kind;
     this.Description = description;
     this.Image       = image;
     this.owner       = new Lazy <Owner>(getOwner);
 }
Esempio n. 11
0
 public Pet(string name, PetKind kind, DateTimeOffset dateOfBirth)
 {
     Name        = name;
     Kind        = kind;
     DateOfBirth = dateOfBirth;
 }
Esempio n. 12
0
 public Pet(string name, PetKind kind)
 {
     Name = name;
     Kind = kind;
 }
Esempio n. 13
0
 public Group(PetKind key, int count)
 {
     Key   = key;
     Count = count;
 }