Esempio n. 1
0
        public HttpResponseMessage DeleteGalleriy(int id)
        {
            var gallery = _galleryService.Find(id);

            gallery.Files.Clear();
            gallery.IsDeleted = true;
            _galleryService.Delete(gallery);
            _unitOfWork.SaveChanges();


            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage Post(CampsCreateViewModel camp)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            var cmp = Mapper.Map <CampsCreateViewModel, Camp>(camp);

            var galleries = cmp.Galleries.ToList();

            cmp.Galleries.Clear();
            cmp.Address.CityId = cmp.Address.City.Id;
            cmp.Address.City   = null;
            _campService.Add(cmp);

            foreach (var item in galleries)
            {
                var item1   = item;
                var gallery = _galleryService.Find(x => x.Id == item1.Id);
                cmp.Galleries.Add(gallery);
            }

            //_campService.Update(cmp);
            _unitOfWork.SaveChanges();

            //  return CreatedAtRoute("DefaultApi", new { id = camp.Id }, camp);
            return(Request.CreateResponse(HttpStatusCode.OK));
        }