Beispiel #1
0
        public async Task <IActionResult> PutAuthenticationUser([FromRoute] int id, [FromBody] AuthenticationUser authenticationUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutCourseAssignments([FromRoute] string id, [FromBody] CourseAssignments courseAssignments)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != courseAssignments.Assignment_Name)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ClassId,Priority,DueDate,Title,Notes,IsComplete")] Assignment assignment)
        {
            if (id != assignment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(assignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssignmentExists(assignment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassId"] = new SelectList(_context.Classes, "Id", "Id", assignment.ClassId);
            return(View(assignment));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Tag tag)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tag);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
Beispiel #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (User.Identity.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    if (ID == 0)
                    {
                        ID = newAssignment.ID;
                    }
                    var tempUser = await assignmentDbContext.Assignments.SingleOrDefaultAsync(m => m.ID == ID);

                    tempUser.DeadlineDay   = newAssignment.DeadlineDay;
                    tempUser.DeadLineMonth = newAssignment.DeadLineMonth;
                    tempUser.DeadlineTime  = newAssignment.DeadlineTime + ":00:00";
                    tempUser.DeadlineYear  = newAssignment.DeadlineYear;
                    assignmentDbContext.Assignments.Update(tempUser);
                    await assignmentDbContext.SaveChangesAsync();

                    return(RedirectToPage("/EditAssignmentsPage"));
                }
                else
                {
                    return(Page());
                }
            }
            else
            {
                return(RedirectToPage("/Error"));
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (User.Identity.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    Assignment addAssignment = new Assignment();
                    addAssignment.AssignmentDescription = newAssignment.AssignmentDescription;
                    addAssignment.AssignmentTitle       = newAssignment.AssignmentTitle;
                    addAssignment.CourseID = newAssignment.CourseID;
                    var course = await courseDbContext.Courses.SingleOrDefaultAsync(m => m.ID == addAssignment.CourseID);

                    addAssignment.CourseName              = course.CourseCode + " - " + course.CourseSemester + " " + course.CourseYear;
                    addAssignment.DeadlineDay             = newAssignment.DeadlineDay;
                    addAssignment.DeadLineMonth           = newAssignment.DeadLineMonth;
                    addAssignment.DeadlineTime            = newAssignment.DeadlineTime + ":00:00";
                    addAssignment.DeadlineYear            = newAssignment.DeadlineYear;
                    addAssignment.AttachmentFulLink       = String.Empty;
                    addAssignment.SubmissionDirectoryLink = String.Empty;
                    await assignmentDbContext.Assignments.AddAsync(addAssignment);

                    await assignmentDbContext.SaveChangesAsync();

                    return(RedirectToPage("/UploadAssignmentAttachmentPage"));
                }
                else
                {
                    return(Page());
                }
            }
            else
            {
                return(RedirectToPage("/Error"));
            }
        }
Beispiel #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (User.Identity.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    if (ID == 0)
                    {
                        ID = newAssignment.ID;
                    }
                    var tempUser = await assignmentDbContext.Assignments.SingleOrDefaultAsync(m => m.ID == ID);

                    assignmentDbContext.Assignments.Remove(tempUser);
                    await assignmentDbContext.SaveChangesAsync();

                    return(RedirectToPage("/EditAssignmentsPage"));
                }
                else
                {
                    return(Page());
                }
            }
            else
            {
                return(RedirectToPage("/Error"));
            }
        }
        public async Task <IActionResult> Create(string classes)
        {
            if (ModelState.IsValid)
            {
                char[]   delimiterChars = { ' ', ',' };
                string[] words          = classes.Split(delimiterChars, System.StringSplitOptions.RemoveEmptyEntries);

                foreach (var word in words)
                {
                    Class newClass = new Class(word);
                    _context.Add(newClass);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction("Added"));
            }
            return(View());
        }
Beispiel #9
0
        public async Task <IActionResult> OnPostAsync(IFormFile file)
        {
            if (file == null || file.Length == 0)
            {
                return(Content("file not selected"));
            }

            var assignment = assignmentDbContext.Assignments.Last();
            var path       = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", assignment.SubmissionDirectoryLink, "attachment" + file.FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await file.CopyToAsync(stream);
            }
            assignment.AttachmentFulLink = Path.Combine(assignment.SubmissionDirectoryLink, "attachment" + file.FileName);
            assignmentDbContext.Assignments.Update(assignment);
            await assignmentDbContext.SaveChangesAsync();

            return(RedirectToPage("/UploadAssignmentAttachmentPage"));
        }
Beispiel #10
0
        public async Task OnGetAsync()
        {
            CurrentProfile = await profileDbContext.Profiles.SingleOrDefaultAsync(m => m.ID == 1);

            if (User.Identity.IsAuthenticated)
            {
                CurrentAssignment = await assignmentDbContext.Assignments.LastOrDefaultAsync();

                var newAssignment = CurrentAssignment;
                if (CurrentAssignment != null)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Assignments", "Assignment" + CurrentAssignment.ID);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    newAssignment.SubmissionDirectoryLink = Path.Combine("Assignments", "Assignment" + CurrentAssignment.ID);
                    assignmentDbContext.Assignments.Update(newAssignment);
                    await assignmentDbContext.SaveChangesAsync();
                }
            }
        }
        public async Task <JsonResult> Add(BusinessEntityAddViewModel model, int?agentId)
        {
            if (ModelState.IsValid)
            {
                /*
                 * Flight APIs, Agent Type, Markup Plan is skipped
                 * Because of not matching with Business Entity Data
                 */
                //Edit
                if (agentId != null)
                {
                    var dbAgent = await _context.BusinessEntities.FirstOrDefaultAsync(f => f.BusinessId == agentId);

                    if (dbAgent == null)
                    {
                        return(Json(new { success = false, message = "Can't find this agent" }));
                    }
                    dbAgent = _mapper.Map(model, dbAgent);
                    dbAgent.UpdatedOnUtc = DateTime.UtcNow;

                    try
                    {
                        _context.Update(dbAgent);
                        await _context.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                        //log
                        Console.WriteLine(e.Message);
                        return(Json(new { success = false, message = "Can't update the agent" }));
                    }

                    return(Json(new { success = true, message = "Successfully Updated Agent" }));
                }


                var businessEntity = new BusinessEntities
                {
                    State         = model.State,
                    Balance       = model.Balance,
                    City          = model.City,
                    Code          = model.Code,
                    ContactPerson = model.ContactPerson,
                    Country       = model.Country,
                    CreatedOnUtc  = DateTime.UtcNow,
                    Email         = model.Email,
                    Mobile        = model.Mobile,
                    Name          = model.Name,
                    Phone         = model.Phone,
                    ReferredBy    = model.ReferredBy,
                    SMTPPassword  = model.SMTPPassword,
                    SMTPPort      = model.SMTPPort,
                    SMTPServer    = model.SMTPServer,
                    SMTPUsername  = model.SMTPUsername,
                    Status        = model.Status,
                    Street        = model.Street,
                    UpdatedOnUtc  = DateTime.UtcNow,
                    SecurityCode  = model.SecurityCode,
                    Zip           = model.Zip,
                    MarkupPlanId  = model.MarkupPlanId,
                    Logo          = await UploadFile(model.LogoFile, model.Name),
                };
                await _context.BusinessEntities.AddAsync(businessEntity);

                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Successfully Added Agent" }));
            }



            return(Json(new { success = false, message = "Something Wrong please check all Inputs" }));
        }