Ejemplo n.º 1
0
        public async Task <IActionResult> AssignmentOverview(string?id, [Bind("Id, UserId, TaskId")] PPSPSAssignment assignment)
        {
            assignment.Id     = Guid.NewGuid().ToString();
            assignment.UserId = User.Identity.GetUserId <string>();
            assignment.TaskId = id;
            assignment.FileId = Guid.NewGuid().ToString();
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(assignment);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(SubmittedTasksOverview)));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Nebylo možné uložit změny. " +
                                         "Zkuste to znovu později a pokud problém přetrvává, " +
                                         "obraťte se na správce systému.");
            }

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> TaskCreate([Bind("TaskName,Description,DateEntered,DateDeadline,ClassId,SubjectId,GroupId,YearsOfStudiesId,File")] PPSPSTask task)
        {
            task.Id        = Guid.NewGuid().ToString();
            task.TeacherId = User.Identity.GetUserId <string>();
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(task);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(TasksOverview)));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Nebylo možné uložit změny. " +
                                         "Zkuste to znovu později, pokud problém přetrvává, " +
                                         "zkontaktujte svého správce systému.");
            }

            PopulateClassesWithoutIdDropDownList(task.ClassId);
            PopulateSubjectDropDownList(task.SubjectId);
            PopulateGroupDropDownList(task.GroupId);
            PopulateYearsOfStudiesDropDownList(task.YearsOfStudiesId);
            return(View(task));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Create(ApplicationRole applicationRole)
        {
            if (ModelState.IsValid)
            {
                _context.Add(applicationRole);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationRole));
        }
        public async Task <IActionResult> Create([Bind("ID,Text,Email")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(View(contact));
        }
Ejemplo n.º 6
0
        public IActionResult CreateGroup(GroupDto groupDto)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var group  = new Group
            {
                Name   = groupDto.Name,
                UserId = userId
            };

            _context.Add(group);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public async Task <IActionResult> Create([Bind("ID,Text,Date,UserID,ProductID")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                comment.Date = DateTime.Now;
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("UserProductDetails", "Products", new { id = comment.ProductID }));
            }
            ViewData["ProductID"] = new SelectList(_context.products, "ID", "Description", comment.ProductID);
            ViewData["UserID"]    = new SelectList(_context.Users, "Id", "Id", comment.UserID);
            return(View(comment));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> ClassCreate([Bind("ClassName, YearOfEntry, ClassTeacherId")]
                                                      PPSPSClass classes)
        {
            classes.Id = Guid.NewGuid().ToString();
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(classes);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(ClassesOverview)));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Nebylo možné uložit změny. " +
                                         "Zkuste to znovu později a pokud problém přetrvává, " +
                                         "obraťte se na správce systému.");
            }

            PopulateClassTeacherDropDownList(classes.ClassTeacherId);
            return(View(classes));
        }
Ejemplo n.º 9
0
        public IActionResult Create(ReminderDto reminderDto)
        {
            var userId   = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var reminder = new Reminder
            {
                Title       = reminderDto.Title,
                Description = reminderDto.Description,
                Date        = DateTime.Now,
                Status      = reminderDto.Status,
                GroupId     = reminderDto.GroupId,
                UserId      = userId
            };

            _context.Add(reminder);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("ID,Name,ImageSrc,Price,Description,CategoryID")] ProductCreateViewModel model)
        {
            Product newProduct = new Product();

            if (ModelState.IsValid)
            {
                string uniqueFileName = ProcessUploadedFile(model);
                newProduct = new Product
                {
                    Name        = model.Name,
                    Price       = model.Price,
                    Description = model.Description,
                    Category    = model.Category,
                    CategoryID  = model.CategoryID,
                    Image       = uniqueFileName
                };
                _context.Add(newProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index2)));
            }
            ViewData["CategoryID"] = new SelectList(_context.categories, "ID", "Name", newProduct.CategoryID);
            return(View(newProduct));
        }