public JobCardViewModel GetJobCard(int Id) { JobCard jobCard = _unitOfWork.JobCardRepository.GetById(Id); if (jobCard == null) { return(null); } List <JobPartsViewModel> jobPartsViews = new List <JobPartsViewModel>(); foreach (JobParts jobPart in jobCard.JobParts) { JobPartsViewModel jobPartView = new JobPartsViewModel(jobPart) { SparePart = new SparePartsViewModel(jobPart.SparePart) }; jobPartsViews.Add(jobPartView); } EmployeeViewModel employee = new EmployeeViewModel(jobCard.Employee); JobCardViewModel jobCardView = new JobCardViewModel(jobCard) { JobParts = jobPartsViews, Employee = employee }; return(jobCardView); }
public async Task <IActionResult> Details(int?id) { JobCardViewModel cardViewModel = new JobCardViewModel() { //var supplier = await _context.Suppliers //.FirstOrDefaultAsync(m => m.SupplierId == id); CustomerOrder = await _context.CustomerOrders.FirstOrDefaultAsync(m => m.CustomerOrderId == id), //CustomerOrderDetail = await _context.CustomerOrderDetails.FirstOrDefaultAsync(m => m.CustomerOrderId == id) CustomerOrderDetail = await _context.CustomerOrderDetails.Include(i => i.CustomerOrder).Include(i => i.ItemMaster) .Where(a => a.CustomerOrderId == id).ToListAsync() /*if (id != null) * { * ViewData["Customer"] = id.Value; * Instructor instructor = viewModel.Instructors.Where( * i => i.ID == id.Value).Single(); * viewModel.Courses = instructor.CourseAssignments.Select(s => s.Course); * }*/ //IEnumerable < CustomerOrderDetail> CustomerOrderDetail = _context.CustomerOrderDetails //.Include(m => m.CustomerOrder) //.Where(a => a.CustomerOrderId == id) //.SingleOrDefault() }; return(View(cardViewModel)); }
public ActionResult Assign(JobCardViewModel jobCardViewModel) { IUnitOfWork testUnit = new UnitOfWork(_context); testUnit.JobCards.SingleOrDefault(s => s.Id == jobCardViewModel.Id); // var job = Mapper.Map <JobCardViewModel, JobCard>(jobCardViewModel); job.ScheduledFor = jobCardViewModel.ScheduledFor; job.JobStatusId = 2; job.CustomerId = jobCardViewModel.CustomerId; var userList = new List <ApplicationUser>(); foreach (var userId in jobCardViewModel.ApplicationUserIdArray) { var user = _context.Users.SingleOrDefault(s => s.Id == userId); userList.Add(user); PushBullet.Assigned(user.Id); } job.ApplicationUsers = userList; testUnit.JobCards.Update(job); testUnit.Complete(); return(RedirectToAction("Index")); }
public IActionResult GetJobCard(int Id) { JobCardViewModel jobCard = _jobCardService.GetJobCard(Id); jobCard.Employee.UserName = HttpContext.User.FindFirstValue(ClaimTypes.Name); return(View(jobCard)); }
/// <summary> /// Send-mail to admin /// </summary> /// <param name="jobCardViewModel"></param> /// <returns></returns> private async Task SendMail(JobCardViewModel jobCardViewModel) { try { string senderID = "SenderMailId"; string senderPassword = "******"; MailMessage mail = new MailMessage(); mail.To.Add("ReceiverMailId"); mail.From = new MailAddress(senderID, "JOB-CARD"); mail.Priority = MailPriority.High; mail.Subject = "Job-Card"; mail.Body = @"<html><head><style>table {font-family: arial, sans-serif;border-collapse: collapse; width: 100%;} th {padding: 10px;font-size: 24px;}td { border: 1px solid #dddddd; text-align: left; padding: 8px;} tr:nth-child(even) { background-color: #dddddd;}</style></head> <body><table><tr><th colspan='3'>Job-Card</th></tr> <tr><td>Name</td><td>" + jobCardViewModel.Name + "</td></tr>" + "<tr><td>Date</td><td>" + jobCardViewModel.CreatedDate.ToShortDateString() + "</td></tr>" + "<tr><td>Service</td><td>" + jobCardViewModel.NatureOfService + "</td></tr>" + "<tr><td>Mobile Number</td><td>" + jobCardViewModel.PhoneNumber + "</td></tr></table></body></html>"; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential (senderID, senderPassword); // ***use valid credentials*** smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(mail); } catch (Exception ex) { throw ex; } }
public ActionResult Edit(int?id) { if (User.IsInRole(UserRoles.Technician)) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JobCard jobCard = _unitOfWork.JobCards.GetJobCardWithCustomer((int)id); if (jobCard == null) { return(HttpNotFound()); } // JobCardViewModel jvm = Mapper.Map <JobCard, JobCardViewModel>(jobCard); JobCard jc = new JobCard(); jvm.Id = jobCard.Id; jvm.CustomerId = (int)jobCard.CustomerId; jvm.Customer = jobCard.Customer; jvm.JobTypeId = jobCard.JobTypeId; jvm.JobStatusId = jobCard.JobStatusId; // jvm.JobStatuses = _unitOfWork.JobStatuses.GetAll().ToList(); jvm.JobTypes = _unitOfWork.JobTypes.GetAll().ToList(); jvm.Staff = _context.Users.ToList(); // return(View("Technician", jvm)); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JobCard jobCard = _unitOfWork.JobCards.Get((int)id); if (jobCard == null) { return(HttpNotFound()); } // JobCardViewModel jvm = new JobCardViewModel(); jvm.Id = jobCard.Id; jvm.CustomerId = (int)jobCard.CustomerId; jvm.JobTypeId = jobCard.JobTypeId; jvm.JobStatusId = jobCard.JobStatusId; // jvm.JobStatuses = _unitOfWork.JobStatuses.GetAll().ToList(); jvm.JobTypes = _unitOfWork.JobTypes.GetAll().ToList(); jvm.Staff = _context.Users.ToList(); // return(View("Admin", jvm)); } }
public IActionResult InsertJob(JobCardViewModel jobCardPost) { if (!ModelState.IsValid) { return(View(jobCardPost)); } _jobCardService.InsertjobCard(jobCardPost); return(View(jobCardPost)); }
public IActionResult UpdateJob(JobCardViewModel jobCardPost) { if (!ModelState.IsValid) { return(View(jobCardPost)); } _jobCardService.UpdateJobCard(jobCardPost); return(RedirectToRoute(new { controller = "JobCard", action = "GetJobCard", jobCardPost.Id })); }
public IActionResult InsertJob([FromQuery] int vehicleId) { JobCardViewModel newJob = new JobCardViewModel { VehicleId = vehicleId, EmployeeId = int.Parse(HttpContext.User.FindFirstValue("EmployeeId")) }; return(View(newJob)); }
public async Task <IActionResult> Index(JobCardViewModel jobCardViewModel) { try { Random r = new Random(); if (ModelState.IsValid) { var job = new JobCards { CreatedDate = DateTime.Now, DateOfCompletion = jobCardViewModel.DateOfCompletion, Designation = jobCardViewModel.Designation, Division = jobCardViewModel.Division, Email = jobCardViewModel.Email, Indentor = jobCardViewModel.Indentor, isAccept = false, isReject = false, isComplete = false, //JobId = "JOB" + r.Next(100000, 999999), Name = jobCardViewModel.Name, NatureOfService = jobCardViewModel.NatureOfService, PhoneNumber = jobCardViewModel.PhoneNumber }; _context.Add(job); _context.SaveChanges(); var temp = job.Id.ToString(); var jobId = "JOB" + temp.PadLeft(6, '0'); var updateJobId = _context.JobCards.FirstOrDefault(x => x.Id == job.Id); updateJobId.JobId = jobId; _context.SaveChanges(); await SendMail(jobCardViewModel); _logger.LogInformation("Add Job Card"); jobCardViewModel.Id = job.Id; jobCardViewModel.JobId = job.JobId; jobCardViewModel.CreatedDate = job.CreatedDate; } return(View(jobCardViewModel)); } catch (Exception ex) { _logger.LogError(ex.Message); throw ex; } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (selectedPart != null) { txtSparePartCode.Clear(); JobCardViewModel spareModel = new JobCardViewModel(); spareModel.PartCode = selectedPart.SPARE_PART.SPARE_PART_CODE; spareModel.PartDescription = selectedPart.SPARE_PART.SPARE_PART_DESCRIPTION; spareModel.PartId = selectedPart.SPARE_PART_ID; spareModel.UnitPrice = selectedPart.SUPPLIER.SPARE_RATEs.Max(s => s.SPARE_RATE_VALUE); lstSpareService.Add(spareModel); gridSpareService.ItemsSource = lstSpareService; gridSpareService.Items.Refresh(); } }
public ActionResult Edit(JobCard jobCard) { if (ModelState.IsValid) { jobCard.LastUpdated = DateTime.Now; _unitOfWork.JobCards.Update(jobCard); _unitOfWork.Complete(); return(RedirectToAction("Index")); } // JobCardViewModel jvm = new JobCardViewModel(); jvm.JobStatuses = _unitOfWork.JobStatuses.GetAll().ToList(); // return(RedirectToAction("Create", "Signature")); }
public ActionResult Assign(int?id) { if (id.HasValue) { // JobCardViewModel jvm = new JobCardViewModel(); jvm.Staff = _context.Users.ToList(); jvm.JobTypes = _unitOfWork.JobTypes.GetAll().ToList(); jvm.Id = (int)id; // return(View(jvm)); } else { return(RedirectToAction("Index")); } }
public void UpdateJobCard(JobCardViewModel jobCardPost) { JobCard jobCard = _unitOfWork.JobCardRepository.GetById(jobCardPost.Id.Value); jobCard.Date = jobCardPost.Date; jobCard.OdometerReading = jobCardPost.OdometerReading; jobCard.Fuel = jobCardPost.Fuel; jobCard.DateIn = jobCardPost.DateIn; jobCard.DateOutEstimated = jobCardPost.DateOutEstimated; jobCard.DateOutActual = jobCardPost.DateOutActual; jobCard.CustomerComment = jobCardPost.CustomerComment; jobCard.JobDescription = jobCardPost.JobDescription; jobCard.Status = jobCardPost.Status; jobCard.EmploeeId = jobCardPost.EmployeeId; jobCard.VehicleId = jobCardPost.VehicleId; _unitOfWork.JobCardRepository.Update(jobCard); _unitOfWork.Save(); _logger.LogInfo($"JobCard for vehicle Id {jobCard.VehicleId} updated"); }
public List <JobCardViewModel> GetJobCard(string searchString) { IEnumerable <JobCard> jobCards = _unitOfWork.JobCardRepository.Get(searchString); if (jobCards == null) { return(null); } List <JobCardViewModel> jobCardsView = new List <JobCardViewModel>(); foreach (JobCard jobCard in jobCards) { JobCardViewModel jobCardView = new JobCardViewModel(jobCard); jobCardsView.Add(jobCardView); } return(jobCardsView); }
public ActionResult Create(JobCardViewModel jobCardViewModel) { if (ModelState.IsValid) { IUnitOfWork testUnit = new UnitOfWork(_context); var job = Mapper.Map <JobCardViewModel, JobCard>(jobCardViewModel); job.CreatedAt = DateTime.Now; job.ScheduledFor = jobCardViewModel.ScheduledFor; var customer = testUnit.Customers.SingleOrDefault(f => f.Id == jobCardViewModel.CustomerId); job.Customer = customer; var userList = new List <ApplicationUser>(); foreach (var userId in jobCardViewModel.ApplicationUserIdArray) { var user = _context.Users.SingleOrDefault(s => s.Id == userId); userList.Add(user); PushBullet.Assigned(userId); } job.ApplicationUsers = userList; testUnit.JobCards.Add(job); testUnit.Complete(); return(RedirectToAction("Index")); /* * Note: * This Code was used to pull the current user as the person the job is allocated to. * //var userId = User.Identity.GetUserId(); * //var userFromDb = _context.Users.SingleOrDefault(u => u.Id == userId); * //job.ApplicationUsers.Add(userFromDb); */ } return(View(jobCardViewModel)); }
public void InsertjobCard(JobCardViewModel jobCardPost) { JobCard jobCard = new JobCard { Date = jobCardPost.Date, OdometerReading = jobCardPost.OdometerReading, Fuel = jobCardPost.Fuel, DateIn = jobCardPost.DateIn, DateOutEstimated = jobCardPost.DateOutEstimated, DateOutActual = jobCardPost.DateOutActual, CustomerComment = jobCardPost.CustomerComment, JobDescription = jobCardPost.JobDescription, Status = jobCardPost.Status, EmploeeId = jobCardPost.EmployeeId, VehicleId = jobCardPost.VehicleId }; _unitOfWork.JobCardRepository.Insert(jobCard); _unitOfWork.Save(); _logger.LogInfo($"JobCard for vehicle Id {jobCard.VehicleId} inserted"); }
public IActionResult DeleteJob(JobCardViewModel jobCardPost) { _jobCardService.DeleteJobCard(jobCardPost); return(RedirectToRoute(new { controller = "Customer", action = "Index" })); }
/// <summary> /// User job-card form page /// </summary> /// <returns></returns> public IActionResult Index() { var jobCard = new JobCardViewModel(); return(View(jobCard)); }