public async Task CreateAssignments() { var invoiceId = Guid.NewGuid(); var assignmentId = AssignmentId.New; await _assignmentService.CreateAssignment(new CreateAssignmentCommand(assignmentId, invoiceId)); var assignment = await _queryProcessor.ProcessAsync(new GetAssignmentByInvoiceIdQuery(invoiceId), CancellationToken.None); Assert.Equal(assignmentId.GetGuid(), assignment.AssignmentId); }
public ActionResult Detail(PDistributorDetailViewModel model) { //var user = Session["admin"] as Account; var pdis = _pdistributorService.GetPDistributor(model.idDistributor); pdis.idDistributor = model.idDistributor; pdis.name = model.name; pdis.Email = model.Email; pdis.address = model.address; pdis.phone = model.phone; pdis.status = model.status; pdis.note = model.note; // var assig = _assigmentService.CreateAssignment(pdis.Assignments.FirstOrDefault().staff, pdis.Assignments.FirstOrDefault().PDistributor); var res = _representativeService.GetRepresentative(pdis.Representatives.FirstOrDefault().idRepresentative); res.name = model.rep_name; res.title = model.title; res.email = model.rep_email; res.phone = model.rep_phone; //var assigTemp = _assigmentService.GetAssignment(pdis.Assignments.FirstOrDefault().staff, pdis.Assignments.FirstOrDefault().PDistributor); var assig = new Assignment(); assig.staff = model.staffAssigment; assig.PDistributor = pdis.idDistributor; assig.date = model.date; assig.place = model.place; if (pdis.status == 3 || pdis.status == 4) { assig.isComplete = true; } assig.isComplete = false; assig.result = model.result; assig.staff = model.staffAssigment; var rs1 = _representativeService.UpdateRepresentative(res); //var rs2 = _assigmentService.DeleteAssignment(assigTemp); var rs3 = _assigmentService.CreateAssignment(assig); pdis.updatedDate = DateTime.Now; var result = _pdistributorService.UpdatePDistributor(pdis); if (result == true) { TempData["success"] = "Thành công"; return(RedirectToRoute("Default", new { controller = "PDistributor", action = "Detail", id = model.idDistributor })); } else { model.idDistributor = model.idDistributor; TempData["fail"] = result; return(View(model)); } }
public IActionResult CreateAssignment(Assignment assignment, int courseId)//för att skappa assig till course use class assig o course id { if (ModelState.IsValid) { _assignmentService.CreateAssignment(assignment, courseId);//samma posion som i interfase return(RedirectToAction(nameof(Index))); } return(View(assignment)); }
public IActionResult CreateAssignment(Assignment assignment) { if (ModelState.IsValid) { _assignmentService.CreateAssignment(assignment); return(RedirectToAction(nameof(Details), new { id = assignment.CourseId })); } return(View(assignment)); }
public async Task <ActionResult> AssignTo(CourseNameViewModel courseModel) { if (this.ModelState.IsValid) { await assignmentService.CreateAssignment(courseModel); return(this.RedirectToAction("Home", "Admin")); } return(this.View(courseModel)); }
public ActionResult <AssignmentViewModel> CreateAssignment([FromBody] AssignmentCreateViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var currentUserId = User.Claims.FirstOrDefault(c => c.Type.Equals(ClaimTypes.NameIdentifier))?.Value; return(_mapper.Map <AssignmentViewModel>( _assignmentService.CreateAssignment(_mapper.Map <AssignmentCreateDTO>(model), currentUserId))); }
public async Task <IActionResult> DirectAssign(DirectAssignmentModel model) { if (ModelState.IsValid) { var assignment = mapper.Map <Assignment>(model); assignment.AddedOn = DateTime.Now; await assignmentService.CreateAssignment(assignment); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <ActionResult> Add(AssignmentViewModel viewModel) { if (ModelState.IsValid) { var assigment = await db.MapData(viewModel); db.CreateAssignment(assigment); await db.SaveChangesAsync(); return(Json(new { success = true, message = "Added Successfully" })); } var dropDownDevelopersProjects = await db.IncludeProjectManagersAndDevelopersDropdown(); ViewBag.Statuses = await db.IncludeStatusesDropdown(); ViewBag.Projects = await db.IncludeProjectsDropdown(); ViewBag.Developers = dropDownDevelopersProjects.Item1; ViewBag.ProjectManagers = dropDownDevelopersProjects.Item2; return(Index()); }
public IActionResult New(AssignmentDetailsViewModel model) { if (!ModelState.IsValid) { return(PromptForSubmission(model)); } else if (model.AssignedTo == AssignedTo.IndividualPlayers && (model.Players == null || model.Players.Count() == 0)) { ModelState.AddModelError("", "Please specify which players this is assigned to"); return(PromptForSubmission(model)); } else if (model.AssignedTo == AssignedTo.SelectedSquads && (model.Squads == null || model.Squads.Count() == 0)) { ModelState.AddModelError("", "Please specify which squads this is assigned to"); return(PromptForSubmission(model)); } var email = User.Identity.Name; var members = memberQuery.GetMembersByEmail(club.Guid, email); var coach = members?.FirstOrDefault(m => m.Membership == Membership.Coach); if (coach == null) { ModelState.AddModelError("", "Coach could not be resolved"); PromptForSubmission(model); } var response = assignmentService.CreateAssignment(new AssignmentRequest { Title = model.Title, ClubId = club.Guid, CoachId = coach.Guid, DueDate = model.DueDate, Instructions = model.Instructions, Players = model.AssignedTo == AssignedTo.IndividualPlayers ? model.Players : null, Squads = model.AssignedTo == AssignedTo.SelectedSquads ? model.Squads : null, TrainingMaterials = model.TrainingMaterials, AssignedTo = model.AssignedTo.Value }); if (!response.RequestIsFulfilled) { foreach (var error in response.Errors) { ModelState.AddModelError("", error); } PromptForSubmission(model); return(View("Create", model)); } return(RedirectToAction(nameof(Index))); }
public IActionResult CreateAssignment(int?id, [Bind("Title, Subject, Description, DueToDate")] Assignment assignment) { if (id != null || id != 0 || ModelState.IsValid) { _assignmentDB.CreateAssignment(assignment); var boolean = _courseDB.AddAssignment(id, assignment); if (boolean) { return(RedirectToAction(nameof(Details), "Course", new { id })); } return(NotFound()); } return(BadRequest()); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(NewAssignmentViewModel request) { var epicId = ParseIntParam(request.EpicId); var epic = repository.Epics .ReadNotDeleted(x => x.Id == epicId) .Include(x => x.Project) .ThenInclude(x => x.Collaborators) .SingleOrDefault(); if (epic is null) { return(GetResponseFailed(Resources.Errors_EpicDoesNotExist)); } var validationResult = ValidateProjectAccess(projectService, epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } var project = validationResult.Project; ApplicationUser user = null; if (request.AssigneeId.HasValue) { var assigneeId = request.AssigneeId; user = userService.GetById(assigneeId.Value); if (user is null || !project.Collaborators.Select(x => x.Collaborator).Contains(user)) { return(GetResponseFailed(Resources.Errors_Unauthorized)); } } assignmentService.CreateAssignment(CurrentApplicationUser, user, epic, request.Deadline, request.Name, request.Description); repository.SaveChanges(); return(GetResponseSuccess(message: Resources.Assignment_Created)); }
public async Task <IActionResult> CreateAssignment([FromBody] CreateAssignmentRequestDto createAssignmentRequestDto) { return(Ok(await _assignmentService.CreateAssignment(createAssignmentRequestDto))); }
public async Task HandleAsync(IReadOnlyCollection <IDomainEvent> domainEvents, CancellationToken cancellationToken) { var domainEvent = domainEvents.Single(); switch (domainEvent.EventType.FullName) { case "Invoice.Core.DomainModel.InvoiceCreatedEvent": { // Initiate process for this invoice var id = domainEvent.GetIdentity(); var invoiceId = Guid.Parse(id.Value.Replace("invoice-", "")); await _assignmentService.CreateAssignment(new CreateAssignmentCommand(AssignmentId.New, invoiceId)); break; } case "Invoice.Core.DomainModel.InvoiceSentEvent": { var id = domainEvent.GetIdentity(); var invoiceId = Guid.Parse(id.Value.Replace("invoice-", "")); var assignment = await _queryProcessor.ProcessAsync(new GetAssignmentByInvoiceIdQuery(invoiceId), CancellationToken.None); await _assignmentService.SetWaitingForPayment(new SetWaitingForPaymentCommand(AssignmentId.With(assignment.AssignmentId), assignment.InvoiceId)); await _paymentService.SetWaitingForPayment(new WaitingForPaymentRequest() { InvoiceId = invoiceId }); var assignmentInvoice = await _queryProcessor.ProcessAsync(new GetAssignmentInvoiceQuery(invoiceId), CancellationToken.None); if (assignmentInvoice.PayInAdvance) { await _payoutService.PayEmployee(new PayEmployeeRequest { InvoiceId = invoiceId }); } break; } case "Payment.Core.DomainModel.PaymentReceivedEvent": { dynamic paymentReceived = domainEvent.GetAggregateEvent(); Guid invoiceId = paymentReceived.InvoiceId; var assignmentInvoice = await _queryProcessor.ProcessAsync(new GetAssignmentInvoiceQuery(invoiceId), CancellationToken.None); if (!assignmentInvoice.PayInAdvance) { await _payoutService.PayEmployee(new PayEmployeeRequest { InvoiceId = invoiceId }); } break; } case "Payment.Core.DomainModel.PaymentDueEvent": { dynamic paymentDue = domainEvent.GetAggregateEvent(); Guid invoiceId = paymentDue.InvoiceId; await _invoiceService.SendReminder(invoiceId); break; } case "Payout.Core.DomainModel.EmployeePaidEvent": { // close assignment dynamic employeePaid = domainEvent.GetAggregateEvent(); Guid invoiceId = employeePaid.InvoiceId; var assignment = await _queryProcessor.ProcessAsync(new GetAssignmentByInvoiceIdQuery(invoiceId), CancellationToken.None); await _assignmentService.CloseAssignment(new CloseAssignmentCommand(AssignmentId.With(assignment.AssignmentId))); break; } } }