コード例 #1
0
        public IHttpActionResult PutEvent(int id, Event @event)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @event.Id)
            {
                return(BadRequest());
            }

            db.Entry(@event).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public async Task <IActionResult> PutReminder(int id, [FromBody] ReminderDTO reminder)
        {
            //check for a bad request
            if (id != reminder.Id)
            {
                return(BadRequest());
            }
            //check if the reminder exists
            if (!ReminderExists(id))
            {
                return(NotFound());
            }

            var dbObject = _context.Reminders.First(x => x.Id == id);

            //change the dto fields
            dbObject.EventId               = reminder.EventId;
            dbObject.Date                  = reminder.EventDate;
            dbObject.Message               = reminder.Message;
            dbObject.Modified              = DateTime.Now;
            dbObject.ModifiedById          = 1; //Exchange for current user
            _context.Entry(dbObject).State = EntityState.Modified;

            try
            {
                //try to save the changes
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "ID,Title,Date,Time,Location")] Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(@event));
 }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "RepID,FirstName,LastName,RegionID,Twitter,Facebook,Instagram,Email,Active")] Reps reps)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reps).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(reps));
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "RegionID,Region")] Regions regions)
 {
     if (ModelState.IsValid)
     {
         db.Entry(regions).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(regions));
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "EventID,EventTitle,EventDirector,EventDistribution,EventTickets,EventReleaseDate")] EventModel eventmodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventmodel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(eventmodel));
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "AreaId,Name")] Area area)
 {
     if (ModelState.IsValid)
     {
         db.Entry(area).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(area));
 }
コード例 #8
0
 public ActionResult Edit(Event event1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(event1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(event1));
 }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "Id,OrderDate,NumOfTickets,User")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "Id,Name")] EventType eventtype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventtype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(eventtype));
 }
コード例 #11
0
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(course));
 }
コード例 #12
0
        public async Task <ActionResult> Edit([Bind(Include = "event_id,event_type,title,description,st_date,e_date,org_name,org_contact,max_ticket,available_ticket,city,state")] tbevent tbevent)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tbevent).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(tbevent));
        }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "Id,AreaId,Name,Address,Capacity,Image")] EventVenue eventvenue)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventvenue).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AreaId = new SelectList(db.Areas, "AreaId", "Name", eventvenue.AreaId);
     return(View(eventvenue));
 }
コード例 #14
0
 public ActionResult Edit([Bind(Include = "Id,EventTypeId,Title,Description,StartDateTime,EndDateTime,LocationCity,LocationState,Organizer,MaxTickets,AvailableTickets")] Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EventTypeId = new SelectList(db.EventTypes, "Id", "Name", @event.EventTypeId);
     return(View(@event));
 }
コード例 #15
0
        public async Task <ActionResult> Edit([Bind(Include = "event_type_ID,event_type1")] Event_Type event_Type)
        {
            if (ModelState.IsValid)
            {
                db.Entry(event_Type).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(event_Type));
        }
コード例 #16
0
 public ActionResult Edit([Bind(Include = "Id,EventTypeId,EventVenueId,EventName,Details,Data")] EventInfo eventinfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eventinfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EventTypeId  = new SelectList(db.EventTypes, "Id", "Name", eventinfo.EventTypeId);
     ViewBag.EventVenueId = new SelectList(db.Venues, "Id", "Name", eventinfo.EventVenueId);
     return(View(eventinfo));
 }
コード例 #17
0
        public async Task <IActionResult> PutBadEvent(int id, BadEventDTO dto)
        {
            // check user Access
            //check for a bad request
            if (id != dto.Id)
            {
                return(BadRequest());
            }
            //check if the event exists
            if (!BadEventExists(id))
            {
                return(NotFound());
            }

            var badEvent = _context.Events.First(x => x.Id == id && !x.IsDeleted && !x.Archived);

            //change the dto fields
            badEvent.Date         = dto.Date;
            badEvent.Message      = dto.Message;
            badEvent.Placement    = dto.Placement;
            badEvent.Reason       = dto.Reason;
            badEvent.SeverityId   = dto.SeverityId;
            badEvent.StatusId     = dto.StatusId;
            badEvent.Modified     = DateTime.Now;
            badEvent.ModifiedById = 1; //Exchange for current user

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

            try
            {
                //try to save the changes
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
コード例 #18
0
ファイル: UsersController.cs プロジェクト: Arerir/DTE-2803
        public async Task <IActionResult> PutUser(int id, [FromBody] UserDTO user)
        {
            //if current user is Admin
            //check for a bad request
            if (id != user.Id)
            {
                return(BadRequest());
            }

            //check if the user exists
            if (!UserExists(id))
            {
                return(NotFound());
            }

            var dbObject = _context.Users.First(x => x.Id == id);

            //change the dto fields
            dbObject.FirstName = user.FirstName;
            dbObject.SirName   = user.SirName;
            dbObject.Password  = !string.IsNullOrEmpty(user.Password) ? GetHashedValue(user.Password) : dbObject.Password;
            dbObject.BirthId   = !string.IsNullOrEmpty(user.Password) ? GetHashedValue(user.BirthId): dbObject.BirthId;
            dbObject.Email     = user.Email;
            dbObject.HasAdmin  = user.HasAdmin;

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

            try
            {
                //try to save the changes
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
コード例 #19
0
 public void Update(data.Event e)
 {
     context.Entry(e).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }