public async Task <IActionResult> PutPaymentType([FromRoute] int id, [FromBody] PaymentType paymentType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PutTasky([FromRoute] Guid id, [FromBody] Tasky tasky)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "ID,Name,Age,Role,BirthDate")] Developers developers)
 {
     if (ModelState.IsValid)
     {
         db.Entry(developers).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(developers));
 }
Example #5
0
 public void InsertOrUpdate(Developers developer)
 {
     if (developer.ID == default(int))
     {
         ctx.Developers.Add(developer);
     }
     else
     {
         ctx.Entry(developer).State = System.Data.Entity.EntityState.Modified;
     }
 }
Example #6
0
        private void Update(int id, string name, int age, DateTime birthdate, Role role, List <int> skills)
        {
            using (DevContext context = new DevContext())
            {
                var updateDeveloper = db.Developers.Where(x => x.ID == id).First();
                updateDeveloper.Name      = name;
                updateDeveloper.Age       = age;
                updateDeveloper.BirthDate = birthdate;
                updateDeveloper.Role      = role;

                updateDeveloper = UpdateSkill(skills, updateDeveloper, context);
                db.Entry(updateDeveloper).State = EntityState.Modified;
                db.SaveChanges();
            }
        }