public IHttpActionResult PutTask(int id, Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.Entry(task).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Edit([Bind(Include = "ExpenseId,Name,Description,PaymentTerm,PaymentAmount,Done")] Expense expense)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expense).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(expense));
 }
 public ActionResult Edit([Bind(Include = "StatusId,TableId,Name")] Status status)
 {
     if (ModelState.IsValid)
     {
         db.Entry(status).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(status));
 }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "MeetingId,Name,Description")] Meeting meeting)
 {
     if (ModelState.IsValid)
     {
         db.Entry(meeting).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(meeting));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "GuestId,Name,Description,Invited,Coming")] Guest guest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(guest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(guest));
 }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "UserId,Mail,PasswordHash,PasswordSalt,FirsName,LastName,EmailConfirmed")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult Edit([Bind(Include = "EventId,Name")] Event @event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(@event));
 }
Exemple #8
0
        public async Task <ActionResult> Edit([Bind(Include = "VotingAnswerId,AnswerText")] VotingAnswer votingAnswer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(votingAnswer).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(votingAnswer));
        }
        public async Task <ActionResult> Edit([Bind(Include = "VotingId,Name,Description,IsOpenQuestion")] Voting voting)
        {
            if (ModelState.IsValid)
            {
                db.Entry(voting).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(voting));
        }
Exemple #10
0
        public async Task EditAsync(T entity)
        {
            Assert.ArgumentIsNull(entity, nameof(entity));

            if (!_context.Set <T>().Local.Any(e => e == entity))
            {
                throw new ArgumentException(
                          "Cannot edit entity, which is not attached to the current context.",
                          nameof(entity));
            }


            var contextEntry = _context.Entry(entity);

            contextEntry.State = EntityState.Modified;

            await _context.SaveChangesAsync();
        }
Exemple #11
0
        async public Task <IHttpActionResult> PutUser(int id, string password)
        {
            User user = new User();

            user = await db.Users.Where(x => x.Id == id).FirstOrDefaultAsync();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (user == null)
            {
                return(BadRequest("User not found with id: " + id));
            }

            user.Password = PasswordHashing(password);

            db.Entry(user).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.OK));
        }