示例#1
0
        public void AddAssignment(AssignmentModel assignmentModel)
        {
            var assign = _iAssignmentMapper.Map(assignmentModel);

            _iAssignmentRepository.Add(assign);
            _iAssignmentRepository.SaveChanges();
        }
 public Assignment Add(Classrooms classrooms, DateTime dueTo, string type, string link, string description)
 {
     return(assignmentRepository.Add(new Assignment()
     {
         Classroom = classrooms, Type = type, PostedDate = DateTime.UtcNow, DueTo = dueTo, Link = link, Description = description, Id = Guid.NewGuid()
     }));
 }
        public IHttpActionResult PostAssignment(Assignment assignment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _assignmentRepository.Add(assignment);

            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception)
            {
                if (AssignmentExists(assignment.StudentId, assignment.ProjectId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = assignment.StudentId }, assignment));
        }
        private async Task <Assignment> CreateAssignment(Question question)
        {
            question.CategoryExhibitor.Exhibitor.GroupsAtExhibitor++;

            // get username from jwt token.
            var username = User.Claims.ElementAt(3).Value;

            // get ApplicationUser via username
            var user = _userManager.Users.Include(u => u.School).SingleOrDefault(u => u.UserName == username);

            // get groupName out of the username (username is a concat of schooName + groupName)
            var groupName = username.Substring(user.School.Name.Length);

            //TODO user should have a groupId, and get group via user and not as done below:
            // get group object via schoolId and groupName
            var group = await _groupRepository.GetBySchoolIdAndGroupName(user.School.Id, groupName);

            // Create assignment and Add to the groups assignments.
            var assignment = new Assignment(question);

            group.AddAssignment(assignment);
            assignment = /*await*/ _assignmentRepository.Add(assignment); //TODO nog niet async.
            await _assignmentRepository.SaveChanges();

            return(assignment);
        }
示例#5
0
        public IActionResult NewAssignment(ClassroomHomeViewModel model)
        {
            string Id = null;

            if (_signInManager.IsSignedIn(HttpContext.User))
            {
                Id = _userManager.GetUserId(HttpContext.User);
            }
            if (ModelState.IsValid)
            {
                string        filename = null;
                List <string> files    = new List <string>();
                if (model.AssignmentViewModel.Files != null)
                {
                    foreach (IFormFile file in model.AssignmentViewModel.Files)
                    {
                        string uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "posted_assignments");
                        filename = Guid.NewGuid().ToString() + "_" + file.FileName;
                        files.Add(filename);
                        string filePath = Path.Combine(uploadsFolder, filename);
                        file.CopyTo(new FileStream(filePath, FileMode.Create));
                    }
                }
                Assignment newAssignment = new Assignment
                {
                    ClassroomID = Convert.ToInt32(model.AssignmentViewModel.ClassId),
                    AppUserID   = Id,
                    Title       = model.AssignmentViewModel.Title,
                    Description = model.AssignmentViewModel.Description,
                    Files       = string.Join(",", files)
                };
                _assignmentRepo.Add(newAssignment);
            }
            return(RedirectToAction("Home", new { id = model.AssignmentViewModel.ClassId, loadPartial = "Assignments" }));
        }
        public string AddAssignment(Assignment assignment)
        {
            string id          = "";
            var    _assignment = _assignmentRepository.GetByWorkOrder(assignment.WorkOrderId);

            if (_assignment == null)
            {
                id                      = Guid.NewGuid().ToString();
                assignment.Id           = id;
                assignment.CreationDate = DateTime.Now;
                assignment.StartDate    = assignment.EstimatedStartDate;
                _assignmentRepository.Add(assignment);
                assignment.Active = false;
            }
            else
            {
                id = _assignment.Id;
                assignment.Active = true;
            }

            assignment.AssignedPersonnel.ForEach(p => {
                p.AssignmentId = id;                 //assignment.Id;
            });
            if (!assignment.Active)
            {
                assignment.Location.AssignmentId = id;                 // assignment.Id;
                _assignmentRepository.AddLocation(assignment.Location);
            }
            _assignmentRepository.AddPersonnel(assignment.AssignedPersonnel);
            return(id);
            //return assignment.Id;
        }
示例#7
0
 public void AddAssignment(AssignmentModel assignment)
 {
     if (laboratoryRepository.GetById(assignment.Laboratory.Id) == null)
     {
         throw new Exception("lab not present");
     }
     assignmentRepository.Add(Mapper.Map <AssignmentDto>(assignment));
     assignmentRepository.Save();
 }
        public IActionResult AddAssignment([FromBody] AssignmentDTO dto)
        {
            return(this.Created(() =>
            {
                bool result = _AssignmentRepo.Add(dto).Equals((int)TransactionStatus.SUCCESS);

                return result ? dto.ToJson() : new JObject();
            }));
        }
示例#9
0
 public async Task <IActionResult> PostAssignment([FromBody] Assignment assignment)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _assignmentRepository.Add(assignment);
     _assignmentRepository.Save();
     return(CreatedAtAction("GetAssignment", new { id = 1 }, assignment));
 }
示例#10
0
 public HttpStatusCodeResult Post(Assignment assignment)
 {
     if (ModelState.IsValid)
     {
         _repository.Add(assignment);
         return(new HttpStatusCodeResult(200));
     }
     else
     {
         return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
     }
 }
示例#11
0
        public async Task <IActionResult> AddAssignment([FromBody] DeviceAssignmentSaveResource saveResource)
        {
            if (!_auth.IsValidUser(User))
            {
                return(NoContent());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (await _deviceRepo.GetDevice(saveResource.DeviceId) == null)
            {
                return(BadRequest($"Device {saveResource.DeviceId} could not be found."));
            }

            if (await _assigneeRepo.GetAssignee(saveResource.AssigneeId) == null)
            {
                return(BadRequest($"Assignee {saveResource.AssigneeId} could not be found."));
            }

            var filter = new MdaAssignmentQuery()
            {
                DeviceId       = saveResource.DeviceId,
                AssignmentType = saveResource.AssignmentType,
                AssigneeId     = saveResource.AssigneeId
            };
            var assigmentFromRepo = await _repo.GetAssignments(filter);

            if (assigmentFromRepo.Any())
            {
                return(BadRequest($"Assignment already exists."));
            }

            var assignment = _mapper.Map <MdaDeviceAssignment>(saveResource);

            assignment.CreatedBy = User.Identity.Name;
            if (saveResource.StartDate == DateTime.MinValue)
            {
                assignment.StartDate = DateTime.Now;
            }

            _repo.Add(assignment);

            if (await _repo.SaveAll())
            {
                return(Ok(assignment));
            }

            return(BadRequest("Failed to add assignment"));
        }
示例#12
0
        public async Task <object> PostAssignmentModel(AssignmentInputModel assignmentInputModel)
        {
            var result = await _assignmentRepository.Add(assignmentInputModel);

            if (result.Equals("bad request"))
            {
                return(BadRequest());
            }
            else
            {
                return(result);
            }
        }
示例#13
0
        public async Task <Guid> HandleAsync(CreateAssignmentCommand command)
        {
            var assignment = new Assignment {
                Title       = command.Title,
                Description = command.Description,
                PublishAt   = command.PublishAt,
                DeadlineAt  = command.DeadlineAt,
                CourseId    = command.CourseId.GetValueOrDefault(),
            };

            await _repository.Add(assignment);

            await _commandStoreService.PushAsync(command);

            return(assignment.Id);
        }
示例#14
0
        public IActionResult Edit(Assignment updatedAssignment)
        {
            int clientId   = 0;
            int employeeId = 0;

            if (updatedAssignment.ClientId > 0 && updatedAssignment.EmployeeId > 0)
            {
                var assignment = _assignmentRepository.Update(updatedAssignment);
                _assignmentRepository.Commit();
                clientId   = assignment.ClientId;
                employeeId = assignment.EmployeeId;
            }
            else
            {
                var assignment = _assignmentRepository.Add(updatedAssignment);
                _assignmentRepository.Commit();
                clientId   = assignment.ClientId;
                employeeId = assignment.EmployeeId;
            }
            //TempData["Message"] = "Assignment data saved";
            return(RedirectToAction("List"));
        }
 public void Add(Assignment Assignment)
 {
     _assignmentRepository.Add(Assignment);
 }
        //public AssignmentService()
        //{
        //    assignmentRepository = new AssignmentRepository();
        //}

        public void Add(AssignmentModel assignmentModel)
        {
            var newAssignment = mapper.map(assignmentModel);

            assignmentRepository.Add(newAssignment);
        }
示例#17
0
 public IActionResult AddAssignment([FromBody] AssignmentDTO dto)
 {
     return(this.Created(() => _AssignmentRepo.Add(dto).Equals(TransactionStatus.SUCCESS)
     ? dto : new AssignmentDTO(), _Logger));
 }