public IHttpActionResult AddPetToUser(AddPetMessage message)
        {
            var users = new Zealous.Domain.Users();
            var result = users.AddPet(message);

            if (!result.HasValue)
                return Unauthorized();

            if(!result.Value)
                return Conflict();

            return Ok();
        }
Example #2
0
        public bool? AddPet(AddPetMessage message)
        {
            using (IDal dal = new ProtoDBContext())
            {
                var user = dal.GetUserByName(Thread.CurrentPrincipal.Identity.Name);

                if (user == null)
                    return null;

                if (user.ID != message.UserId)
                    return null;
                var petmapper = new ProtoPetMap(dal);

                return dal.AddPet(petmapper.Map(message.Model) as IPet);
            }
        }