示例#1
0
        public bool CreateDog(DogCreate model)
        {
            var entity =
                new Dog()
            {
                Name     = model.Name,
                ClientId = model.ClientId,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Dogs.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#2
0
 public bool CreateDog(DogCreate model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var newDog = new Dog()
         {
             DogName = model.DogName,
             Weight  = model.Weight,
             Breed   = model.Breed,
             OwnerId = model.OwnerId
         };
         ctx.Dogs.Add(newDog);
         return(ctx.SaveChanges() == 1);
     }
 }
        public ActionResult Create(DogCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (CreateDogService().CreateDog(model))
            {
                TempData["SaveResult"] = "Dog created";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Error creating a Dog");
            return(View(model));
        }
示例#4
0
        //post the dog
        public IHttpActionResult Post(DogCreate dog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateDogServices();

            if (!service.CreateDog(dog))
            {
                return(InternalServerError());
            }

            return(Ok($"{dog.Name} has been posted to Bootz & Catz! ▼・ᴥ・▼"));
        }
示例#5
0
        public ActionResult Create(DogCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new DogService();

            if (service.CreateDog(model))
            {
                TempData["SaveResult"] = "Your dog was added.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Dog could not be added.");
            return(View(model));
        }
示例#6
0
        public bool CreateDog(DogCreate model)
        {
            var entity =
                new Dog()
            {
                DogName   = model.DogName,
                DogBreed  = model.DogBreed,
                DogSex    = model.DogSex,
                DogWeight = model.DogWeight,
                DogAge    = model.DogAge,
                DogPrice  = model.DogPrice,
                DogImage  = model.DogImage,
                ShelterId = model.ShelterId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Dogs.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
示例#7
0
        //create dogggggggs 4days
        public bool CreateDog(DogCreate model)
        {
            var entity =
                new Dog()
            {
                IsChipped   = model.IsChipped,
                EnergyLevel = model.EnergyLevel,
                Size        = model.Size,
                Name        = model.Name,
                Breed       = model.Breed,
                Age         = model.Age,
                AboutMe     = model.AboutMe,
                ShelterId   = model.ShelterId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Dogs.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }