public IHttpActionResult AddHorse(HorseApiModel horse) { var httpRequest = HttpContext.Current.Request; //if (httpRequest.Files.Count < 1) //{ // return (IHttpActionResult)Request.CreateResponse(HttpStatusCode.BadRequest); //} //foreach (string file in httpRequest.Files) //{ // var postedFile = httpRequest.Files[file]; // var filePath = HttpContext.Current.Server.MapPath("~/UploadedFiles" + postedFile.FileName); // postedFile.SaveAs(filePath); // horse.ImagePaths.Add(filePath); //} int result = _horseBusiness.AddHorse(horse); if (result > 0) { return(Ok("Horse with Id:" + result + " created successfully")); } else { return(Ok("Horse not created")); } }
//public HorseBusiness(IHorseRepository horseRepository) { // _horseRepository = horseRepository; //} public int AddHorse(HorseApiModel horse) { tblHors newHorse = new tblHors { Breed = horse.Breed, Color = horse.Color, Other = horse.Other, Size = horse.Size, UserId = horse.UserId }; return(_horseRepository.AddHorse(newHorse, horse.ImagePaths)); }