예제 #1
0
        public string SaveUserDetails(UserModel model)
        {
            try
            {
                Random rnd        = new Random();
                int    myRandomNo = rnd.Next(10000000, 99999999);
                model.Password = UtilityController.Encrypt(Convert.ToString(myRandomNo), "CRYPTI");

                Int64 RecordID = model.SaveUserDetails();
                if (RecordID > 0)
                {
                    model.UserID = RecordID;
                    //model = model.GetUserDetails();
                    //SendUserDetailsInEmail(model.Username, UtilityController.Decrypt(Convert.ToString(model.Password), "CRYPTI"), model.EmailID, model.FirstName, model.LastName);
                }
            }
            catch (Exception ex)
            {
                UtilityController.LogException(ex, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name);
            }
            return("");
        }
예제 #2
0
        public void Utility_ShowUtilities_View_Contains_3_Utilities()
        {
            Mock <IUtilityRepository> mock = new Mock <IUtilityRepository>();

            mock.Setup(m => m.UTILITYs).Returns(new UTILITY[]
            {
                new UTILITY {
                    ID = 1, NAME = "Electricity"
                },
                new UTILITY {
                    ID = 2, NAME = "Water"
                },
                new UTILITY {
                    ID = 3, NAME = "Gas"
                }
            }.AsQueryable());

            UtilityController controller = new UtilityController(mock.Object);

            UtilityModel actual = (UtilityModel)controller.ShowUtilities().Model;

            Assert.AreEqual(3, actual.Utilities.Count);
        }
예제 #3
0
 private void btn_search_Click(object sender, EventArgs e)
 {
     if (tbox_search.Text != "Rechercher...")
     {
         pnl_utilities.Controls.Clear();
         var utilities = UtilityController.getAll(); // .OrderBy(t => t.id).Reverse()
         utilities = utilities.Where(u => u.name.Contains(tbox_search.Text) || u.description.Contains(tbox_search.Text));
         foreach (var u in utilities)
         {
             pnl_utilities.Controls.Add(new uc_UtilityModel
             {
                 id          = u.id,
                 molecule_id = u.molecule_id,
                 name        = u.name,
                 description = u.description
             });
         }
     }
     else
     {
         ReloadPanel();
     }
 }
예제 #4
0
        private void LoadAnalytic()
        {
            cartesianChart_MoneyByTime.Series.Clear();
            cartesianChart_MoneyByTime.AxisX.Clear();
            cartesianChart_MoneyByTime.AxisY.Clear();
            pieChart_ContractsByCompany.Series.Clear();
            pieChart_UtilitiesByMolecule.Series.Clear();

            #region CartesianChart
            cartesianChart_MoneyByTime.AxisX.Add(new Axis
            {
                Title  = "Mois",
                Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
            });
            cartesianChart_MoneyByTime.AxisY.Add(new Axis
            {
                Title          = "Revenue",
                LabelFormatter = value => value.ToString("C2")
            });
            SeriesCollection series = new SeriesCollection();
            var request             = ContractController.getYears();
            for (int year = request.Item1; year <= request.Item2; year++)
            {
                List <double> values = new List <double>();
                for (int month = 0; month <= 12; month++)
                {
                    values.Add(ContractController.getPriceFromMonth(year, month));
                }
                series.Add(new LineSeries()
                {
                    Title = year.ToString(), Values = new ChartValues <double>(values)
                });
            }
            cartesianChart_MoneyByTime.Series         = series;
            cartesianChart_MoneyByTime.LegendLocation = LegendLocation.Right;
            #endregion

            #region pieChart
            var companies = CompanyController.getAll();
            Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
            foreach (var company in companies)
            {
                var contracts = ContractController.getByCompany(company.id);
                pieChart_ContractsByCompany.Series.Add(new PieSeries
                {
                    Title  = company.name,
                    Values = new ChartValues <double> {
                        contracts.Count()
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                });
            }
            pieChart_ContractsByCompany.LegendLocation = LegendLocation.Bottom;
            var molecules = MoleculeController.getAll();
            foreach (var molecule in molecules)
            {
                var utilities = UtilityController.getByMolecule(molecule.id);
                pieChart_UtilitiesByMolecule.Series.Add(new PieSeries
                {
                    Title  = molecule.real_name,
                    Values = new ChartValues <double> {
                        utilities.Count()
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                });
            }
            pieChart_UtilitiesByMolecule.LegendLocation = LegendLocation.Bottom;
            #endregion

            // Load all chart
            cartesianChart_MoneyByTime.Hide();
            cartesianChart_MoneyByTime.Show();
            pieChart_ContractsByCompany.Hide();
            pieChart_ContractsByCompany.Show();
            pieChart_UtilitiesByMolecule.Hide();
            pieChart_UtilitiesByMolecule.Show();
        }
예제 #5
0
 public UtilityControllerTest()
 {
     _repository        = new RepositoryWrapper(_eIA_DEVContext);
     _utilityController = new UtilityController(_logger, _repository);
 }
예제 #6
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     UtilityController.Delete(id);
     uc_MainUtility.Instance.ReloadPanel();
     this.SendToBack();
 }
예제 #7
0
        public void ClearDb()
        {
            var utilityController = new UtilityController();

            utilityController.ClearDb();
        }
 public StarterApi_IsTestValid()
 {
     _utilityController = new UtilityController();
 }
예제 #9
0
        public ADUserModel(string city, string name, string department, string description,
                           string displayname, string employeeid, string givenname, string officephone, string initials,
                           string office, string postalcode, string samaccountname, string state, string streetaddress,
                           string surname, string title, string userprincipalname, string path, string ipphone,
                           string msExchHideFromAddressList, string changepasswordatlogon, string enabled, string type, string accountPassword)
        {
            string LogMessage = "NewADUser|name: " + name + "|city: " + city + "|department: " + department + "|description: " + description + "|" +
                                "displayname: " + displayname + "|employeeid: " + employeeid + "|givenname: " + givenname + "|officephone: " + officephone +
                                "|initials: " + initials + "|office: " + office + "|postalcode: " + postalcode + "|samaccountname: " + samaccountname + "|state: " + state
                                + "|streetaddress: " + streetaddress + "|surname: " + surname + "|title: " + title + "|type: " + type + "|userprincipalname: " +
                                userprincipalname + "|path: " + path + "|ipphone: " + ipphone + "|msExchHideFromAddressList: " + msExchHideFromAddressList +
                                "|changepasswordatlogon: " + changepasswordatlogon + "|enabled: " + enabled;
            UtilityController util = new UtilityController();

            util.LogMessage(LogMessage);
            if (name != "")
            {
                this.name = name;
            }
            if (city != "")
            {
                this.city = city;
            }

            /*if (country != "")
             *  this.country = country;*/
            if (department != "")
            {
                this.department = department;
            }
            if (description != "")
            {
                this.description = description;
            }
            if (displayname != "")
            {
                this.displayname = displayname;
            }
            if (employeeid != "")
            {
                this.employeeid = employeeid;
            }
            if (givenname != "")
            {
                this.givenname = givenname;
            }
            if (officephone != "")
            {
                this.officephone = officephone;
            }
            if (initials != "")
            {
                this.initials = initials;
            }
            if (office != "")
            {
                this.office = office;
            }
            if (postalcode != "")
            {
                this.postalcode = postalcode;
            }
            if (samaccountname != "")
            {
                this.samaccountname = samaccountname;
            }
            if (state != "")
            {
                this.state = state;
            }
            if (streetaddress != "")
            {
                this.streetaddress = streetaddress;
            }
            if (surname != "")
            {
                this.surname = surname;
            }
            if (title != "")
            {
                this.title = title;
            }
            if (userprincipalname != "")
            {
                this.userprincipalname = userprincipalname;
            }
            if (path != "")
            {
                this.path = path;
            }
            if (ipphone != "")
            {
                this.ipphone = ipphone;
            }
            if (msExchHideFromAddressList != "")
            {
                this.msExchHideFromAddressList = msExchHideFromAddressList;
            }

            if (changepasswordatlogon != "")
            {
                if (changepasswordatlogon.ToLower() == "true")
                {
                    this.changepasswordatlogon = true;
                }
                else if (changepasswordatlogon.ToLower() == "false")
                {
                    this.changepasswordatlogon = false;
                }
            }

            if (enabled != "")
            {
                if (enabled.ToLower() == "true")
                {
                    this.enabled = true;
                }
                else if (enabled.ToLower() == "false")
                {
                    this.enabled = false;
                }
            }
            if (accountPassword != "")
            {
                this.accountPassword = accountPassword;
            }
            if (type != "")
            {
                this.type = type;
            }
        }