Ejemplo n.º 1
0
        public async Task <IActionResult> Create(TechnicianViewModel model)

        {
            if (ModelState.IsValid)
            {
                string imageFileName = FirstImageUploadedFile(model);


                Technician technician = new Technician
                {
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    Address         = model.Address,
                    DateRegistered  = DateTime.Now,
                    EmailAddress    = model.EmailAddress,
                    CertificatePath = imageFileName,
                    PhoneNumber     = model.PhoneNumber
                };
                _context.Add(technician);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Completed)));
            }
            return(View(model));
        }
Ejemplo n.º 2
0
 //Update List of the cases that haven't been started yet
 private void UpdateComingList(object sender, RoutedEventArgs e)
 {
     //Sets DataTable to listview
     lsvComingCases.DataContext = TechnicianViewModel.GetWorkOrders("'Registered'");
     //Sets selected item to the first item
     lsvComingCases.SelectedIndex = 0;
 }
Ejemplo n.º 3
0
        private void BtnSkip_Click(object sender, RoutedEventArgs e)
        {
            selected = (Case)spDeviceData.DataContext;
            SkippedCaseView view = new SkippedCaseView(selected, LoggedUser);

            view.Show();

            try
            {
                TechnicianViewModel.SetCaseStatus(selected, "Skipped");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Työtilausta ei voitu ohittaa. \n" + ex.Message);
            }

            try
            {
                UpdateComingList(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Uutta työtilausta ei voitu hakea. \n" + ex.Message);
            }
        }
Ejemplo n.º 4
0
        public void Fail_Return_Success()
        {
            //Setup
            string ApiVersion = "V1";
            int    StatusCode = 200;
            string Message    = "OK";

            TechnicianViewModel viewModel = new TechnicianViewModel();
            ResultFormatter     formatter = new ResultFormatter(ApiVersion, StatusCode, Message);
            var validationContext         = new System.ComponentModel.DataAnnotations.ValidationContext(viewModel);

            var errorData = new
            {
                WarningError = "Format Not Match"
            };

            string error     = JsonConvert.SerializeObject(errorData);
            var    exception = new ServiceValidationException(validationContext, new List <ValidationResult>()
            {
                new ValidationResult(error, new List <string>()
                {
                    "WarningError"
                })
            });

            //Act
            var result = formatter.Fail(exception);

            //Assert
            Assert.True(0 < result.Count());
        }
Ejemplo n.º 5
0
        //Setting case to diagnose status and show the started case
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            selected = (Case)lsvComingCases.SelectedItem;
            try
            {
                TechnicianViewModel.SetCaseStatus(selected, "Diagnose");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            TechnicianCurrentCaseView view = new TechnicianCurrentCaseView(selected, LoggedUser);

            view.Show();
            try
            {
                UpdateComingList(sender, e);
            }
            catch (Exception)
            {
                throw;
            }
            //lsvComingCases.DataContext = TechnicianViewModel.GetWorkOrders("'Registered'");
            //lsvComingCases.SelectedIndex = 0;
        }
Ejemplo n.º 6
0
        public static ReportItemStatus ThreeYearStatus(this TechnicianViewModel technician)
        {
            if (technician == null)
            {
                return(ReportItemStatus.Unknown);
            }

            var lastCheck = technician.DateOfLast3YearCheck.GetValueOrDefault().Date;
            var now       = DateTime.Now.Date;

            if (lastCheck > now)
            {
                return(ReportItemStatus.Unknown);
            }

            var expiration = lastCheck.Date.AddYears(3).Date;
            var checkDue   = expiration.AddMonths(-1).Date;

            if (now >= checkDue && now <= expiration)
            {
                return(ReportItemStatus.CheckDue);
            }
            if (now < checkDue)
            {
                return(ReportItemStatus.Ok);
            }
            return(ReportItemStatus.Expired);
        }
        public void Validate_Throws_ServiceValidationExeption()
        {
            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();
            TechnicianViewModel     viewModel       = new TechnicianViewModel();

            ValidateService service = new ValidateService(serviceProvider.Object);

            Assert.Throws <ServiceValidationException>(() => service.Validate(viewModel));
        }
Ejemplo n.º 8
0
 private void CmbStatus_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         TechnicianCurrentCaseViewModel.SetCaseStatus(jobOrder.Id, cmbStatus.SelectedItem.ToString().Split(':')[1].Trim());
         TechnicianViewModel.LogStatusChange(jobOrder.Id, cmbStatus.SelectedItem.ToString().Split(':')[1].Trim());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Jokin meni pieleen!/n" + ex.Message);
     }
     MessageBox.Show(cmbStatus.SelectedItem.ToString().Split(':')[1].Trim());
 }
Ejemplo n.º 9
0
 public ReceivePartView(Part part)
 {
     InitializeComponent();
     this.part = part;
     spReceivePart.DataContext = part;
     try
     {
         workOrder = TechnicianViewModel.GetWorkOrder(part.CaseId);
     }
     catch (Exception)
     {
         MessageBox.Show("Työtilauksen haku epäonnistui");
     }
 }
Ejemplo n.º 10
0
        public void Validate_Technician()
        {
            var dbContext       = DbContext(GetCurrentMethod());
            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            ColorReceiptFacade facade = new ColorReceiptFacade(serviceProvider, dbContext);

            var data = new TechnicianViewModel();

            System.ComponentModel.DataAnnotations.ValidationContext validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(data, serviceProvider, null);
            var response = data.Validate(validationContext);

            Assert.NotEmpty(response);
            Assert.False(data.IsDefault);
        }
        public IActionResult Technician(int id)
        {
            var techVm = new TechnicianViewModel();

            if (id == 0)
            {
                techVm = new TechnicianViewModel();
                return(View(techVm));
            }
            else
            {
                techVm.Technician = _techrepo.GetTechnicianById(id);
                return(View(techVm));
            }
        }
Ejemplo n.º 12
0
        private string FirstImageUploadedFile(TechnicianViewModel model)
        {
            string imageFileName = null;

            if (model.Certificate != null)
            {
                string uploadsfolder = Path.Combine(hostingEnvironment.WebRootPath, "certificates");
                imageFileName = Guid.NewGuid().ToString() + " _" + model.Certificate.FileName;
                string filePath = Path.Combine(uploadsfolder, imageFileName);

                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.Certificate.CopyTo(fileStream);
                }
            }

            return(imageFileName);
        }
Ejemplo n.º 13
0
 //Search individual cases from database
 private void BtnSearch_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int  temp = Convert.ToInt32(txtCaseId.Text);
         Case job  = TechnicianViewModel.GetWorkOrder(temp);
         if (job.Id == 0)
         {
             MessageBox.Show("Keikkaa ei löydy");
         }
         else
         {
             TechnicianCurrentCaseView view = new TechnicianCurrentCaseView(job, LoggedUser);
             view.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Tapahtui virhe\n" + ex.Message);
     }
 }
Ejemplo n.º 14
0
        public static ReportItemStatus HalfYearStatus(this TechnicianViewModel technician)
        {
            if (technician == null || technician.DateOfLastCheck == null)
            {
                return(ReportItemStatus.Unknown);
            }

            var lastCheck    = technician.DateOfLastCheck.GetValueOrDefault();
            var nextCheckDue = lastCheck.AddMonths(6).AddDays(-7).Date;
            var expiration   = lastCheck.AddMonths(6).Date;
            var now          = DateTime.Now.Date;

            if (now >= nextCheckDue && now <= expiration)
            {
                return(ReportItemStatus.CheckDue);
            }
            if (now >= lastCheck && now < nextCheckDue)
            {
                return(ReportItemStatus.Ok);
            }
            return(ReportItemStatus.Expired);
        }
Ejemplo n.º 15
0
 public static bool TryDeleteTechnician(TechnicianViewModel thisModel)
 {
     bool deleteSuccess = false;
     if (thisModel == null) return deleteSuccess;
     using (var db = new RepairCenterModelFirstContainer())
     {
         var techQuery = db.Technicians.FirstOrDefault(x => x.TechID == thisModel.TechID);
         if (techQuery != null)
         {
             if (techQuery.Status != TechnicianStatus.Busy)
             {
                 db.Technicians.Remove(techQuery);
                 db.SaveChanges();
                 deleteSuccess = true;
             }
             else
             {
                 System.Windows.MessageBox.Show("Technician is currently busy.");
             }
         }
     }
     return deleteSuccess;
 }
Ejemplo n.º 16
0
        public void Fail_Throws_Exception()
        {
            //Setup
            string ApiVersion = "V1";
            int    StatusCode = 200;
            string Message    = "OK";

            TechnicianViewModel viewModel = new TechnicianViewModel();
            ResultFormatter     formatter = new ResultFormatter(ApiVersion, StatusCode, Message);
            var validationContext         = new System.ComponentModel.DataAnnotations.ValidationContext(viewModel);
            var exception = new ServiceValidationException(validationContext, new List <ValidationResult>()
            {
                new ValidationResult("errorMessaage", new List <string>()
                {
                    "WarningError"
                })
            });

            //Act
            var result = formatter.Fail(exception);

            //Assert
            Assert.True(0 < result.Count());
        }
Ejemplo n.º 17
0
 private void LsvReadyCases_Loaded(object sender, RoutedEventArgs e)
 {
     lsvReadyCases.DataContext = TechnicianViewModel.GetWorkOrders("'Ready'");
 }
Ejemplo n.º 18
0
 private void StackPanel_Loaded_4(object sender, RoutedEventArgs e)
 {
     lsvWaitingCustomerOrders.DataContext   = TechnicianViewModel.GetWorkOrders("'Waiting customer'");
     lsvWaitingCustomerOrders.SelectedIndex = 0;
 }
Ejemplo n.º 19
0
 private void StackPanel_Loaded_3(object sender, RoutedEventArgs e)
 {
     lsvCostEstimateOrders.DataContext   = TechnicianViewModel.GetWorkOrders("'Cost estimate'");
     lsvCostEstimateOrders.SelectedIndex = 0;
 }
Ejemplo n.º 20
0
 private void StackPanel_Loaded_1(object sender, RoutedEventArgs e)
 {
     lsvPartsDeliveredOrders.DataContext   = TechnicianViewModel.GetWorkOrders("'Waiting parts' AND PartsOnOrder=0");
     lsvPartsDeliveredOrders.SelectedIndex = 0;
 }
Ejemplo n.º 21
0
 //Updates the started cases list
 private void UpdateCurrentWorkOrderList(object sender, RoutedEventArgs e)
 {
     lsvCurrentWorkOrders.DataContext   = TechnicianViewModel.GetWorkOrders("'Diagnose'");
     lsvCurrentWorkOrders.SelectedIndex = 0;
 }