예제 #1
0
        public void Update(Camp camp)
        {
            var obj = _context.Camps.FirstOrDefault(c => c.CampId == camp.CampId);

            obj.Bookings    = camp.Bookings;
            obj.Capacity    = camp.Capacity;
            obj.Description = camp.Description;
            obj.Image       = camp.Image;
            obj.Name        = camp.Name;
            obj.Price       = camp.Price;
            obj.Rating      = camp.Rating;

            _context.Entry(obj).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
        }
예제 #2
0
        public ActionResult Index(User us, HttpPostedFileBase image)
        {
            db.Entry(us).State = EntityState.Modified;
            db.SaveChanges();

            byte[] imageData = null;

            using (var binaryReader = new BinaryReader(image.InputStream))
            {
                imageData = binaryReader.ReadBytes(image.ContentLength);
            }

            var att = new Attachment
            {
                Type  = "Image",
                Bytes = imageData
            };

            db.Attachments.Add(att);

            us = db.Users.Find(1);
            us.Attachment.Add(att);
            db.SaveChanges();

            ViewBag.User = us;

            return(View());
        }
예제 #3
0
        public async Task <IActionResult> PutCampCreateModel(int id, CampCreateModel campCreateModel)
        {
            if (id != campCreateModel.CampId)
            {
                return(BadRequest());
            }

            _context.Entry(campCreateModel).State = EntityState.Modified;

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

            return(NoContent());
        }
예제 #4
0
        public RedirectResult Update(CampPlace cp)
        {
            db.Entry(cp).State = EntityState.Modified;
            db.SaveChanges();

            return(Redirect("/CampPlaces/Index"));
        }
예제 #5
0
        public async Task <IActionResult> PutCamp([FromRoute] int id, [FromBody] Camp camp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != camp.CampId)
            {
                return(BadRequest());
            }

            _context.Entry(camp).State = EntityState.Modified;

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

            return(NoContent());
        }
예제 #6
0
        public int[] SetAndGetRatings(string bookingRef, int rating)
        {
            var obj = _context.Bookings.FirstOrDefault(s => s.BookingReferenceNo == bookingRef);

            obj.Rating = rating;

            _context.Entry(obj).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();

            return(_context.Bookings.Where(s => s.Rating != 0 && s.CampId == obj.CampId).Select(s => s.Rating).ToArray());
        }