Example #1
0
        public CustomerCard(Customer currentCustomer)
        {
            CustomerGuid = currentCustomer.CustomerGuid;
            Title = currentCustomer.Person.Title.ToString();
            FirstName = currentCustomer.Person.FirstName;
            LastName = currentCustomer.Person.LastName;
            PhotoIdentity = currentCustomer.Person.PhotoIdentity;
            PhoneNumber = currentCustomer.Person.PhoneNumber;
            EmailAdress = currentCustomer.Person.EmailAdress;
            HomeAdress = currentCustomer.Person.HomeAdress;
            PersonGuid = currentCustomer.Person.PersonGuid;
            Company = currentCustomer.Company;
            Status = currentCustomer.CustomerStatus.ToString();


            //using (var db = new StationContext())
            //{
            //    var currentInscription = db.Enrollements.Where(e => e.StudentGuid == currentCustomer.StudentGuid).OrderByDescending(e => e.DateAdded).FirstOrDefault();

            //    if (currentInscription != null)
            //    {

            //        CurrentClasseLevel = currentInscription.Classe.Sigle;
            //        CurrentFiliere = currentInscription.Classe.Filiere.Sigle;
            //    }
            //    else
            //    {
            //        CurrentClasseLevel = "Non Inscrit";
            //        CurrentFiliere = "Non Inscrit";
            //    }
            //}
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="myCustomer"></param>
        /// <returns></returns>
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.StaffWrite)]
        public bool UpdateCustomer(Customer myCustomer)
        {
            using (var db = new StationContext())
            {
                // ReSharper disable once PossibleNullReferenceException
                var userTrace = (Guid)Membership.GetUser().ProviderUserKey;                
                myCustomer.LastEditDate = DateTime.Now;
                myCustomer.LastEditUserGuid = userTrace;

                db.Customers.Attach(myCustomer);
                db.Entry(myCustomer).State = EntityState.Modified;

                db.Set<Person>().Attach(myCustomer.Person);
                db.Entry(myCustomer.Person).State = EntityState.Modified;

                return db.SaveChanges() > 0;
            }
        }
Example #3
0
        public NewClient(Guid clientToModGuid)
        {
            InitializeComponent();

            new Task(() => {
                Dispatcher.BeginInvoke(new Action(() => {

                    _CIVILITE_.ItemsSource = EnumsHelper.GetAllValuesAndDescriptions<PersonTitles>();
                    _STATUT.ItemsSource = EnumsHelper.GetAllValuesAndDescriptions<CustomerStatus>();

                    _NATIONALITY.ItemsSource = App.Store.Customers.AllNationalities();

                    if (clientToModGuid == Guid.Empty)
                    {
                        _isAdd = true;

                        var obj = new Customer
                        {
                            Matricule = App.Store.Customers.NewMatricule(),

                            CustomerStatus = CustomerStatus.Default,

                            Person = new Person
                            {
                                Title = PersonTitles.Mr,
                                HealthState = HealthStates.Normal,
                                BirthDate = DateTime.Today.AddYears(-20)
                            }                            
                        };
                        _GRID.DataContext = obj;
                    }
                    else
                    {
                        var data = App.Store.Customers.GetCustomer(clientToModGuid);
                        _PHOTO_IDENTITY.Source = ImagesHelper.DecodePhoto(data.Person.PhotoIdentity);
                        _MATRICULE_VALIDATOR.IsAdd = false;
                        _GRID.DataContext = data;

                        _MATRICULE.IsEnabled = false;
                    }
                }));
            }).Start();
        }
Example #4
0
        /// <summary>
        /// Represente un client
        /// </summary>
        /// <param name="newCustomer"></param>
        /// <exception cref="InvalidOperationException">CAN_NOT_CREAT_STAFF_PROFILE</exception>
        /// <returns></returns>
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.CustomerWrite)]
        public bool AddCustomer(Customer newCustomer) 
        {
            Guard.WhenArgument(newCustomer.Person.FullName, "CUSTOMER_NAME_CAN_NOT_BE_EMPTY").IsNullOrEmpty().IsEqual("Inconnue").Throw();

            using (var db = new StationContext())
            {
                if (newCustomer.CustomerGuid == Guid.Empty)
                    newCustomer.CustomerGuid = Guid.NewGuid();
                if (newCustomer.Person.PersonGuid == Guid.Empty)
                    newCustomer.Person.PersonGuid = Guid.NewGuid();

                // ReSharper disable once PossibleNullReferenceException
                var userTrace = (Guid) Membership.GetUser().ProviderUserKey;
                newCustomer.DateAdded = DateTime.Now;
                newCustomer.AddUserGuid = userTrace;
                newCustomer.LastEditDate = DateTime.Now;
                newCustomer.LastEditUserGuid = userTrace;

                db.Set<Person>().Add(newCustomer.Person);
                db.Customers.Add(newCustomer);
                return db.SaveChanges() > 0;
            }
        }