Beispiel #1
0
        public async Task <IActionResult> PutAssignment(string id, Assignment assignment)
        {
            if (id != assignment.Name)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> WriteReview([FromBody] ReviewViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Review review = new Review
                    {
                        CustomerName = model.CustomerName,
                        IsHide       = model.IsHide,
                        ProductId    = model.ProductId,
                        ProductName  = model.ProductName,
                        Rating       = model.Rating,
                        Review1      = model.Review1
                    };

                    await _context.Reviews.AddAsync(review);

                    await _context.SaveChangesAsync();

                    return(Ok(review));
                }
                return(BadRequest("Something went wrong"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));

                throw;
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("UserId,UserName,Gender,DateRegistration,SelectedDay1,SelectedDay2,SelectedDay3,AdditionalRequest,IsActive")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Code,Name,Description,SemesterOffered,SemesterOffered2,PrereqCourseCode,Compulsory")] Courses courses)
        {
            if (ModelState.IsValid)
            {
                _context.Add(courses);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(courses));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("RollNumber,FullName,Email,Avartar,Address,Phone,Birthday,Admission,UpdateAt,Status")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("Id,UserName,Password,Salt,CreatedAt,UpdatedAt,Status,Role")] Account account)
        {
            if (ModelState.IsValid)
            {
                account.GenerateSalt();
                account.EncryptPassword();
                _context.Add(account);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
        public async Task <Assignment> AddAssignmentAsync(Assignment newAssignment)
        {
            _context.Assignments.Add(newAssignment);
            await _context.SaveChangesAsync();

            return(newAssignment);
        }
        public async Task <IActionResult> RegisterAsync([FromBody] Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _context.Customers.AddAsync(customer);

                    await _context.SaveChangesAsync();
                }
                return(Ok(customer));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));

                throw;
            }
        }