Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,UserName,Gender,DateRegistration,SelectedDay1,SelectedDay2,SelectedDay3,AdditionalRequest,IsActive")] User user)
        {
            if (id != user.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,UserName,Password,Salt,CreatedAt,UpdatedAt,Status,Role")] Account account)
        {
            if (id != account.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(string id, [Bind("Code,Name,Description,SemesterOffered,SemesterOffered2,PrereqCourseCode,Compulsory")] Courses courses)
        {
            if (id != courses.Code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(courses);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoursesExists(courses.Code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(courses));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(long id, [Bind("RollNumber,FullName,Email,Avartar,Address,Phone,Birthday,Admission,UpdateAt,Status")] Student student)
        {
            if (id != student.RollNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.RollNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> UpdateAsync([FromBody] Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                return(Ok(customer));
            }
            catch (Exception ex)
            {
                return(BadRequest("Sorry"));

                throw;
            }
        }