Exemple #1
0
        protected override void RegistrationChanged(string registrationNumber)
        {
            if (string.IsNullOrEmpty(registrationNumber))
            {
                return;
            }

            if (!UndownloadabilityRepository.Any())
            {
                return;
            }

            //Remove all spaces from registration number
            Document.RegistrationNumber = registrationNumber.Replace(" ", "").ToUpper();

            var match = UndownloadabilityRepository.Where(doc => string.Equals(doc.RegistrationNumber, Document.RegistrationNumber, StringComparison.CurrentCultureIgnoreCase))
                        .OrderByDescending(doc => doc.Created)
                        .FirstOrDefault();

            if (match != null)
            {
                Document = match;
                SelectedCustomerContact = CustomerContacts.FirstOrDefault(c => string.Equals(c.Name, Document.CustomerContact, StringComparison.CurrentCultureIgnoreCase));
            }
        }
        private void OnSave(object obj)
        {
            if (string.IsNullOrEmpty(NewCustomerContact.Name) || NewCustomerContact.Name.Length < 2)
            {
                ShowError(Resources.TXT_CUSTOMER_SETTINGS_ENTER_CUSTOMER_NAME);
                return;
            }

            var customerContact = NewCustomerContact.Clone <CustomerContact>();

            if (IsEditing && SelectedIndex > -1)
            {
                CustomerContacts[SelectedIndex] = customerContact;
            }
            else
            {
                CustomerContacts.Add(customerContact);
            }

            Reset();
            Repository.AddOrUpdate(customerContact);
            Saved(customerContact);

            CustomerContacts.Clear();
            CustomerContacts.AddRange(Repository.GetAll().OrderBy(c => c.Name));
        }
        public void ProcessContacts()
        {
            logger.LogInformation($"Inicio el proceso de [{nameFileXml}]: {DateTimeOffset.Now}");
            var contacts = this.GetContacts();

            if (contacts == null)
            {
                this.logger.LogInformation($"No existe información de los {nameFileXml}");
                return;
            }

            this.managementFile.CreateFileCsv <CustomerContactsEntitie>(nameFileXml, contacts);
            var contactsXml = new CustomerContacts {
                Contactos = contacts.ToList()
            };

            this.managementFile.CreateFileXml <CustomerContacts>(nameFileXml, contactsXml);
            logger.LogInformation($"Archivo [{nameFileXml}] con {contacts.Count()} registros generado con éxito.");

            var resultValidatioWithXsd = this.validationXsd.ValidationShemaXml($"{nameFileXml}.xsd", $"{nameFileXml}.xml");

            if (resultValidatioWithXsd.Length > 0)
            {
                logger.LogWarning(resultValidatioWithXsd);
                return;
            }
            logger.LogInformation($"La validación del XSD se realizo con éxito");

            logger.LogInformation($"Finalizo el proceso de [{nameFileXml}]: {DateTimeOffset.Now} \n");
        }
        public void DeleteCustomerContact(int id)
        {
            CustomerContacts _customercontact = _customerContactRepository.GetById(id);

            _customerContactRepository.Delete(_customercontact);
            _customerContactRepository.SaveChanges();
        }
        public CustomerContacts AddorUpdate(CustomerContacts customerContacts)
        {
            _customerContactRepository.AddOrUpdate(customerContacts);
            _customerContactRepository.SaveChanges();


            return(customerContacts);
        }
Exemple #6
0
        public IHttpActionResult GetCustomerContacts(int id)
        {
            CustomerContacts customerContacts = db.CustomerContacts.Find(id);

            if (customerContacts == null)
            {
                log.Error($"GetCustomerContacts method: Customer id {id} did not found");
                return(NotFound());
            }

            return(Ok(customerContacts));
        }
Exemple #7
0
        protected override void BeforeLoad()
        {
            if (MainWindow != null)
            {
                MainWindow.ModalClosedEvent += OnSmallModalClosed;
            }

            if (!IncludeDeletedContacts)
            {
                CustomerContacts.Remove(c => c.IsDeleted);
            }
        }
Exemple #8
0
        private void Populate()
        {
            TachographMakes = new ObservableCollection <TachographMake>(TachographMakesRepository.GetAll("Models"));
            Technicians     = new ObservableCollection <Technician>(TechnicianRepository.GetAll());

            Technician defaultTechnician = Technicians.FirstOrDefault(technician => technician != null && technician.IsDefault);

            if (defaultTechnician != null)
            {
                Document.Technician = defaultTechnician.Name;
            }
            SelectedCustomerContact = CustomerContacts.FirstOrDefault(c => string.Equals(c.Name, Document.CustomerContact, StringComparison.CurrentCultureIgnoreCase));
        }
Exemple #9
0
        public IHttpActionResult PostCustomerContacts(CustomerContacts customerContacts)
        {
            if (!ModelState.IsValid)
            {
                log.Error($"PostCustomerContacts method: Invalid ModelState for Customer Contact with id {customerContacts.Id}");
                return(BadRequest(ModelState));
            }

            db.CustomerContacts.Add(customerContacts);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = customerContacts.Id }, customerContacts));
        }
Exemple #10
0
        public IHttpActionResult DeleteCustomerContacts(int id)
        {
            CustomerContacts customerContacts = db.CustomerContacts.Find(id);

            if (customerContacts == null)
            {
                log.Error($"DeleteCustomer method: Customer did {id} not found");
                return(NotFound());
            }

            db.CustomerContacts.Remove(customerContacts);
            db.SaveChanges();

            return(Ok(customerContacts));
        }
        public Object GetContactByCustomerId(int customerId)
        {
            CustomerContacts customerContacts = _customerContactRepository.Single(a => a.CustomerId == customerId);

            if (customerContacts != null)
            {
                return(new
                {
                    CustomerContacts = new { data = customerContacts, total = 1 },
                });
            }
            else
            {
                return(null);
            }
        }
Exemple #12
0
 private void OnNewCustomerSelected(ModalClosedEventArgs e)
 {
     if (e.Saved)
     {
         CustomerContacts.Add((CustomerContact)e.Parameter);
         CustomerContact[] sorted = CustomerContacts.OrderBy(c => c.Name).ToArray();
         CustomerContacts.Clear();
         foreach (CustomerContact item in sorted)
         {
             CustomerContacts.Add(item);
             if (item == e.Parameter)
             {
                 SelectedCustomerContact = item;
             }
         }
     }
 }
Exemple #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CustomerContacts custContacts = null;
            int errorCode = 0;
            try
            {
                if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtContactNumber.Text))
                {
                    custContacts = new CustomerContacts();
                    custContacts.ContactNumber = txtContactNumber.Text;
                    if (txtName.Text.Length < 3)
                    {
                        MessageBox.Show("Kindly fill in the Name field.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        errorCode = 1;
                    }
                    else
                    {
                        custContacts.Name = this.txtName.Text;
                    }
                    if (IsValidEmail(txtEmail.Text))
                    {
                        custContacts.Email = txtEmail.Text;
                    }
                    else
                    {
                        MessageBox.Show("Kindly fill in a valid email address.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        errorCode = 1;

                    }



                    if (errorCode == 0)
                    {
                        controller.AddCustomerContacts(custContacts.Name, custContacts.Email, custContacts.ContactNumber, CustomerID);
                    }
                }
            }
            catch (Exception ex)
            {
                custContacts = null;
                MessageBox.Show(ex.Message, "Fatal-error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


        }
Exemple #14
0
        //IModelObserverable
        public void UpdateBusinessView(Dictionary<string, IList> updates)
        {
            CustomerContacts custContacts = null;
            try
            {
                List<CustomerContacts> listOfCustomerContacts = (List<CustomerContacts>)updates[GetBusinessViewState()];
                //Clear view data.
                if (customerContactsListView.Items.Count > 0)
                {
                    for (int x = customerContactsListView.Items.Count - 1; x >= 0; x--)
                    {
                        customerContactsListView.Items[x].Remove();                       
                    }
                }
                //Fill view data.
                if (listOfCustomerContacts.Count > 0)
                {
                    ListViewItem listItem = null;
                    for (int z = 0; z < listOfCustomerContacts.Count; z++)
                    {
                        custContacts = new CustomerContacts();
                        custContacts = listOfCustomerContacts[z];

                        if (custContacts.CustomerID == CustomerID)
                        {
                            listItem = new ListViewItem(custContacts.ID.ToString());
                            listItem.SubItems.Add(custContacts.Name);
                            listItem.SubItems.Add(custContacts.Email);
                            listItem.SubItems.Add(custContacts.ContactNumber);

                            customerContactsListView.Items.Add(listItem);
                        }
                    }
                }              
            }
            catch (Exception e)
            {
                MessageBox.Show("An excpetion occured in updating the Customer's contacts view.", "Fatal-error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            GC.Collect();
            ClearScreenInputs();


        }
Exemple #15
0
        public IHttpActionResult PutCustomerContacts(int id, CustomerContacts customerContacts)
        {
            if (!ModelState.IsValid)
            {
                log.Error($"PutCustomerContacts method: InValid ModelState fosr Customer Contact with id {id}");
                return(BadRequest(ModelState));
            }

            if (id != customerContacts.Id)
            {
                log.Error($"PutCustomerContacts method: Wrong Customer id {id}");
                return(BadRequest());
            }

            db.MarkAsModifiedContact(customerContacts);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerContactsExists(id))
                {
                    log.Error($"PutCustomerContacts method: Customer id {id} did not found");
                    return(NotFound());
                }
                else
                {
                    log.Error("PutCustomerContacts method: Exception thrown in db.SaveChanges()");
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void OnRemove(object obj)
 {
     Repository.Remove(SelectedCustomerContact);
     CustomerContacts.Remove(SelectedCustomerContact);
 }
 public void MarkAsModifiedContact(CustomerContacts customerContacts)
 {
 }
Exemple #18
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int errorCode = 0;
            CustomerContacts custContacts = null;
            char[] removeID = new char[] { 'I', 'D', 'i', 'd', ':', ' ' };

            try
            {
                if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtContactNumber.Text))
                {
                    custContacts = new CustomerContacts();
                    
                    
                    custContacts.ContactNumber = txtContactNumber.Text;
                    custContacts.CustomerID = CustomerID;
                    if (lblID.Text.Length > 4)
                    {
                        custContacts.ID = int.Parse(lblID.Text.TrimStart(removeID));
                    }else
                    {
                        errorCode = 1;
                        MessageBox.Show("Kindly select a customer's contacts to be updated.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (txtName.Text.Length > 2)
                    {
                        custContacts.Name = txtName.Text;
                    }
                    else
                    {
                        errorCode = 1;
                        MessageBox.Show("Kindly fill in the Name field.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }


                    if (IsValidEmail(txtEmail.Text))
                    {
                        custContacts.Email = txtEmail.Text;
                    }
                    else
                    {
                        errorCode = 1;
                        MessageBox.Show("Sorry, that email is not valid.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }

                }
                else
                {
                    errorCode = 1;
                    MessageBox.Show("Kindly fill in valid fields.", "Whoops!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }



                if (errorCode == 0)
                {
                    controller.UpdateCustomerContacts(custContacts.ID, custContacts.Name, custContacts.Email, custContacts.ContactNumber, custContacts.CustomerID);
                }
            }
            catch (Exception ex)
            {
                errorCode = 1;
                MessageBox.Show(ex.Message, "Fatal-error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }



        }
        protected override void RegistrationChanged(string registrationNumber)
        {
            if (string.IsNullOrEmpty(registrationNumber) || !Document.IsDigital)
            {
                return;
            }

            //Remove all spaces from registration number
            Document.RegistrationNumber = registrationNumber.Replace(" ", string.Empty).ToUpper();

            if (!TachographDocumentRepository.Any())
            {
                return;
            }

            TachographDocument match = TachographDocumentRepository.Where(doc => string.Equals(doc.RegistrationNumber, Document.RegistrationNumber, StringComparison.CurrentCultureIgnoreCase))
                                       .OrderByDescending(doc => doc.Created)
                                       .FirstOrDefault();

            if (match == null && registrationNumber.Length > 8)
            {
                match = TachographDocumentRepository.Where(doc => string.Equals(doc.VIN, registrationNumber, StringComparison.CurrentCultureIgnoreCase))
                        .OrderByDescending(doc => doc.Created)
                        .FirstOrDefault();
            }

            if (match == null)
            {
                return;
            }

            Document.CalibrationTime  = DateTime.Now;
            Document.CardSerialNumber = match.CardSerialNumber;

            if (Document.Created == default(DateTime))
            {
                Document.Created = DateTime.Now;
            }
            Document.CustomerContact               = match.CustomerContact;
            Document.InspectionDate                = DateTime.Now;
            Document.InspectionInfo                = match.InspectionInfo;
            Document.IsDigital                     = match.IsDigital;
            Document.MinorWorkDetails              = match.MinorWorkDetails;
            Document.Office                        = match.Office;
            Document.RegistrationNumber            = match.RegistrationNumber;
            Document.SerialNumber                  = match.SerialNumber;
            Document.TachographAdapterLocation     = match.TachographAdapterLocation;
            Document.TachographAdapterSerialNumber = match.TachographAdapterSerialNumber;
            Document.TachographCableColor          = match.TachographCableColor;
            Document.TachographHasAdapter          = match.TachographHasAdapter;
            Document.TachographMake                = match.TachographMake;
            Document.TachographModel               = match.TachographModel;
            Document.TachographType                = match.TachographType;
            Document.Tampered                      = match.Tampered;
            Document.TyreSize                      = match.TyreSize;
            Document.VehicleMake                   = match.VehicleMake;
            Document.VehicleModel                  = match.VehicleModel;
            Document.VehicleType                   = match.VehicleType;
            Document.VIN = match.VIN;

            SelectedCustomerContact = CustomerContacts.FirstOrDefault(c => string.Equals(c.Name, match.CustomerContact, StringComparison.CurrentCultureIgnoreCase));
        }