public static void Test_add_with_just_line_properly_adds_record( ) { var newRecord = PreferencesHelpers.GenerateRandomRecord(new Random( )); foreach (var separatorChar in PreferencesHelpers.SupportedDelimiters) { //LastName | FirstName | Gender | FavoriteColor | DateOfBirth //LastName, FirstName, Gender, FavoriteColor, DateOfBirth //LastName FirstName Gender FavoriteColor DateOfBirth var asLine = UnitTestHelpers.GenerateLine(newRecord, separatorChar); var model = new PreferencesModel( ); model.Add(asLine); var added = model.PersonColorPreferences.Single( ).NotNull( ); UnitTestHelpers.AssertRecordIdentical(newRecord, added); } }
public void DefaultPersonColorPreferences( ) { var actual = new PreferencesModel( ); Assert.NotNull(actual); var enum1 = actual.PersonColorPreferences; var enum2 = actual.PersonColorPreferences; Assert.False(ReferenceEquals(enum1, enum2)); var records1 = actual.PersonColorPreferences.ToList( ); Assert.Empty(records1); var records2 = actual.PersonColorPreferences.ToList( ); Assert.Empty(records2); }
private PreferencesModel EnsurePreferencesData(PreferencesModel infoFromFile) { if (infoFromFile == null || string.IsNullOrEmpty(infoFromFile.UnusualSellMultplier) || string.IsNullOrEmpty(infoFromFile.StrangeSellMultiplier) || string.IsNullOrEmpty(infoFromFile.OthersSellMultiplier) || string.IsNullOrEmpty(infoFromFile.UnusualBuyMultiplier) || string.IsNullOrEmpty(infoFromFile.StrangeBuyMultiplier) || string.IsNullOrEmpty(infoFromFile.OthersBuyMultiplier)) { this.fileWriter.WriteDataToFile( this.LocalFolder, LocalData.UserPreferences, JsonConvert.SerializeObject(this.GeneratePreferencesModel())); infoFromFile = JsonConvert.DeserializeObject <PreferencesModel>( this.fileReader.ReadDataFromFile( this.LocalFolder, LocalData.UserPreferences)); } return(infoFromFile); }
public void NewRunModel() { StablePairsEvaluation stablePairsEvaluation = new StablePairsEvaluation(); GroupHappinessEvaluation groupHappinessEvaluation = new GroupHappinessEvaluation(); EgalitarianHappinessEvaluation egalitarianHappinessEvaluation = new EgalitarianHappinessEvaluation(); NewModel(); SetupModel setupModel = _model.NewSetupModel(); setupModel.Initialize(); ParticipantsModel participantsModel = _model.NewParticipantsModel(); participantsModel.Initialize(); PreferencesModel preferencesModel = _model.NewPreferencesModel(); preferencesModel.Initialize(); AlgorithmModel algorithmModel = _model.NewAlgorithmModel(); algorithmModel.Initialize(); RunModel runModel = _model.NewRunModel(); runModel.Initialize(); int receivedEvents = 0; Task task; NewModel(); runModel.AlgorithmStarted += (object sender, AlgorithmEventArgs e) => receivedEvents++; runModel.AlgorithmFinished += (object sender, AlgorithmEventArgs e) => { receivedEvents++; Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(stablePairsEvaluation), e.StablePairs); Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(groupHappinessEvaluation), e.GroupHappiness); Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(egalitarianHappinessEvaluation), e.EgalitarianHappiness); }; task = Task.Run(async() => { await runModel.RunSingleAlgorithm(0); Assert.AreEqual(2, receivedEvents); }); }
public ActionResult Create(PreferencesModel model) { var userClaims = User.Identity as System.Security.Claims.ClaimsIdentity; ViewBag.Name = userClaims?.FindFirst("name")?.Value; if (model.DietaryRestrictions == null) { model.DietaryRestrictions = new List <EdamamService.Health>(); } PreferenceEntity preferences = new PreferenceEntity(userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value, userClaims?.FindFirst(System.IdentityModel.Claims.ClaimTypes.Name)?.Value) { dietPreference = model.Diet.ToString(), healthPreference = string.Join(",", model.DietaryRestrictions.Select(x => x.ToString())) }; TableActions.AddRow("PreferenceTable", (TableEntity)preferences); return(View("Index", model)); }
private void NewModel() { _context = new ModelContext(); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); ParticipantsModel participantsModel = new ParticipantsModel(_context); participantsModel.Initialize(); PreferencesModel preferencesModel = new PreferencesModel(_context); preferencesModel.Initialize(); AlgorithmModel algorithmModel = new AlgorithmModel(_context); algorithmModel.Initialize(); algorithmModel.CreateGaleShapleyAlgorithm(); algorithmModel.CreateGeneticAlgorithm(); _model = new RunModel(_context); _model.Initialize(); _context.AlgorithmsChanged = false; }
public MainApp() { pm = new PreferencesModel(prefsPath); //dbm = new MySqlPartsDb(); dbm = new SqlPartsDb(); mv = new MainView(); pm.Changed += new EventHandler(PrefsChanged); mv.PrefsView.OnSavePrefs += pm.Save; mv.RawSqlView.OnSQLExecute += SQLExecute; mv.PartsView.OnShowParts += ShowParts; mv.PartsView.OnEditPart += EditPart; mv.PartsView.OnNewPart += NewPart; mv.PartsView.OnDeletePart += DeletePart; mv.PartsView.OnRepairMissingAttributes += RepairMissingAttributes; mv.PartEditView.OnSavePart += SavePart; pm.Load(); dbm.GetPartTypes(delegate(List<PartType> partTypes) { mv.PartsView.PartTypes = partTypes; }, null); }
public MainApp() { pm = new PreferencesModel(prefsPath); //dbm = new MySqlPartsDb(); dbm = new SqlPartsDb(); mv = new MainView(); pm.Changed += new EventHandler(PrefsChanged); mv.PrefsView.OnSavePrefs += pm.Save; mv.RawSqlView.OnSQLExecute += SQLExecute; mv.PartsView.OnShowParts += ShowParts; mv.PartsView.OnEditPart += EditPart; mv.PartsView.OnNewPart += NewPart; mv.PartsView.OnDeletePart += DeletePart; mv.PartsView.OnRepairMissingAttributes += RepairMissingAttributes; mv.PartEditView.OnSavePart += SavePart; pm.Load(); dbm.GetPartTypes(delegate(List <PartType> partTypes) { mv.PartsView.PartTypes = partTypes; }, null); }
public ActionResult Preferences() { //Run auto meal scheduler Tasks task = new Tasks(); task.autoScheduler(); if (Session["user"] != null) { UserSessionModel session = (UserSessionModel)Session["user"]; if (session.acctype == "m") { string response = ""; PreferencesModel pm = new PreferencesModel(); pm.getPrefrences(); if (pm.response == "500") { response = "e"; } else { response = "s"; ViewBag.MealRate = pm.mealrate; ViewBag.ServiceCharge = pm.servicecharge; } ViewBag.PrefResponse = response; ViewBag.ManagerName = getManagerName(); return(View()); } else { return(RedirectToAction("UserLogin", "User")); } } else { return(RedirectToAction("UserLogin", "User")); } }
private void LoadPreferences() { preferencesLogic = new PreferencesModel(); //Group Settings LoadGroup(); //System Settings txtFileServer.Text = preferencesLogic.GetPreferencesByName("FileServer").Value; txtThumbPath.Text = preferencesLogic.GetPreferencesByName("ThumbnailPath").Value; txtWebmasterEmail.Text = preferencesLogic.GetPreferencesByName("WebmasterEmail").Value; //Module Settings cbSearchBoxModule.Checked = Boolean.Parse(preferencesLogic.GetPreferencesByName("SearchModule").Value); cbLoginBoxModule.Checked = Boolean.Parse(preferencesLogic.GetPreferencesByName("LoginModule").Value); cbMostViewRateBoxModule.Checked = Boolean.Parse(preferencesLogic.GetPreferencesByName("MostViewMostRateModule").Value); cbRandomDownloadBoxModule.Checked = Boolean.Parse(preferencesLogic.GetPreferencesByName("RandomMostDownloadModule").Value); cbCategoryModule.Checked = Boolean.Parse(preferencesLogic.GetPreferencesByName("CategoryModule").Value); txtMostViewRateBoxModuleAmount.Text = preferencesLogic.GetPreferencesByName("MostViewMostRate_Amount").Value; txtRandomDownloadBoxModuleAmount.Text = preferencesLogic.GetPreferencesByName("RandomMostDownload_Amount").Value; }
private void NewViewModel() { _context = new ModelContext(); _model = new RunModel(_context); _viewModel = new RunViewModel(_model, _context); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); ParticipantsModel participantsModel = new ParticipantsModel(_context); participantsModel.Initialize(); PreferencesModel preferencesModel = new PreferencesModel(_context); preferencesModel.Initialize(); AlgorithmModel algorithmModel = new AlgorithmModel(_context); algorithmModel.Initialize(); algorithmModel.CreateGaleShapleyAlgorithm(); algorithmModel.CreateGeneticAlgorithm(); _viewModel.RefreshPage(); }
/// <summary> /// Create new model /// </summary> private void NewModel() { List <Participant> participants = new List <Participant>(); for (int i = 0; i < 5; i++) { participants.Add(new Participant(i, "test" + i, MarriageGroup.Group1)); } for (int i = 5; i < 10; i++) { participants.Add(new Participant(i, "test" + i, MarriageGroup.Group2)); } _context = new ModelContext { TotalSize = 10, Participants = participants, SetupChanged = true, ParticipantsChanged = true }; _model = new PreferencesModel(_context); _model.Initialize(); _context.PreferencesChanged = false; }
public PreferencesModel GetNewModel(string route) { if (File.Exists(route)) { try { using (var s = new StreamReader(route)) { string json = s.ReadToEnd(); model = JsonConvert.DeserializeObject <PreferencesModel>(json); } } catch { InitializeModel(); } } else { InitializeModel(); } return(model); }
public async Task <IActionResult> Preferences(int?userId) { if (userId != null) { HttpContext.Session.SetString(nameof(userId), userId.ToString()); } else if (HttpContext.Session.GetString(nameof(userId)) != null) { userId = Convert.ToInt32(HttpContext.Session.GetString(nameof(userId))); } else { TempData["message"] = "Please log in."; return(Redirect("/Home/Index")); } var favouritePlatforms = await _context.UserPlatformFavouritePlatform .Include(t => t.Platform) .Include(t => t.User) .Where(t => t.UserId == userId) .ToListAsync(); var favouriteCategories = await _context.UserCategoryFavouriteCategory .Include(t => t.Category) .Include(t => t.User) .Where(t => t.UserId == userId) .ToListAsync(); PreferencesModel preferences = new PreferencesModel(); preferences.FavouritePlatforms = favouritePlatforms; preferences.FavouriteGameCategories = favouriteCategories; return(View(preferences)); }
public void SaveData() { NewModel(); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); ParticipantsModel participantsModel = new ParticipantsModel(_context); participantsModel.Initialize(); PreferencesModel preferencesModel = new PreferencesModel(_context); preferencesModel.Initialize(); AlgorithmModel algorithmModel = new AlgorithmModel(_context); algorithmModel.Initialize(); _model.SaveAsData(""); Assert.IsNotNull(_persistence.MockData); Assert.IsNotNull(_persistence.MockData.Group1Name); Assert.IsNotNull(_persistence.MockData.Group2Name); Assert.IsNotNull(_persistence.MockData.Participants); Assert.IsNotNull(_persistence.MockData.Preferences); Assert.IsNotNull(_persistence.MockData.Algorithms); }
public PreferencesView(PreferencesModel model) { InitializeComponent(); InitializeUI(model); }
public DisplayView(PreferencesModel preferences) { this.preferences = preferences; InitBrushes(); }
protected void btnUpload_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (fileUpload.HasFile && IsPDFFile(fileUpload.FileName)) { prefencesLogic = new PreferencesModel(); cvLetter = new ConvertLetter(); FileName = cvLetter.ClearAccent(fileUpload.FileName).ToLower().Replace(' ', '_'); FilePath = prefencesLogic.GetPreferencesByName("FileServer").Value; FileSize = fileUpload.PostedFile.ContentLength; MaxFileSize = 50 * 1024 * 1024; //Upload Thumbnails if (thumbUpload.HasFile) { String FileExtension = System.IO.Path.GetExtension(thumbUpload.FileName).ToLower(); ThumbnailFileName = System.IO.Path.GetRandomFileName(); ThumbnailPath = prefencesLogic.GetPreferencesByName("ThumbnailPath").Value; thumbUpload.SaveAs(MapPath(new Uri(ThumbnailPath).AbsolutePath + "/" + ThumbnailFileName + FileExtension)); } //Upload Document if (FileSize < MaxFileSize) { fileUpload.SaveAs(MapPath(new Uri(FilePath + @"/" + FileName).AbsolutePath)); docLogic = new DocumentModel(); collectionLogic = new CollectionModel(); tagsLogic = new TagsModel(); int addedCollectionID = 0; int addedDocumentID = 0; //Add Document if (String.IsNullOrEmpty(txtCollectionName.Text)) { addedDocumentID = docLogic.AddDocument( txtDocumentName.Text, txtDescription.Text, ThumbnailFileName, FileName, FileSize, UserID, Int32.Parse(ddlCategory.SelectedValue), ddlCollection.Items.Count != 0 ? Int32.Parse(ddlCollection.SelectedValue) : 0 ); } else { addedCollectionID = collectionLogic.AddCollection(txtCollectionName.Text, String.Empty, UserID); addedDocumentID = docLogic.AddDocument(txtDocumentName.Text, txtDescription.Text, ThumbnailFileName, FileName, FileSize, UserID, Int32.Parse(ddlCategory.SelectedValue), addedCollectionID); } //Add Tags if (!String.IsNullOrEmpty(txtTags.Text)) { tagsLogic.AddTag(txtTags.Text, addedDocumentID, null); } else { String tmpTags = txtDocumentName.Text.Replace(" ", ","); tagsLogic.AddTag(tmpTags, addedDocumentID, null); } blInfo.Items.Add("Thêm tài liệu thành công"); } else { blInfo.Items.Add("Dung lượng file cho phép không quá 50MB"); } } else { blInfo.Items.Add("Sai định dạng file. Chỉ cho phép định dạng PDF"); } } } catch (ApplicationException ex) { blInfo.Items.Clear(); blInfo.Items.Add(ex.Message); } }
private void processReport(string month, string year) { //Get all users string response = ""; UsersModel usm = new UsersModel(); List <UsersModel> usList = new List <UsersModel>(); //Get preferences PreferencesModel pm = new PreferencesModel(); pm.getPrefrences(); foreach (UsersModel user in usm.getAllUsers()) { usList.Add(user); } if (usm.response == "500") { response = "e"; } else { response = "s"; int totalMeals = 0; int totalMealCost = 0; int serviceCharge = 0; int totalCost = 0; string showing = ""; string costInfo = ""; string details = ""; //Check for valid date input bool isValid = false; string date = year + "-" + month + "-01"; DateTime dt2; if (DateTime.TryParse(date, out dt2)) { isValid = true; int inM = (int)dt2.Month; int inY = (int)dt2.Year; month = inM.ToString(); year = inY.ToString(); } else { isValid = false; } //Get member's meal info foreach (UsersModel u in usList) { List <SelfMealsModel> smList = new List <SelfMealsModel>(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); SelfMealsModel smm = new SelfMealsModel(); GuestMealsModel gmm = new GuestMealsModel(); smm.memberId = u.id; gmm.memberId = u.id; foreach (SelfMealsModel sm in smm.getAllMealByMemberId()) { smList.Add(sm); } foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberId()) { gmList.Add(gm); } //List by month and year List <SelfMealsModel> smlistByMonth = new List <SelfMealsModel>(); List <GuestMealsModel> gmlistByMonth = new List <GuestMealsModel>(); //List by month if (isValid) { showing = getMonth(month) + ", " + year; //Get self list by month foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } else { //Get list by current month showing = "Current Month"; month = getCurrentMonth(); year = getCurrentYear(); foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } //Get totals int totalSelf = 0; int totalGuest = 0; foreach (SelfMealsModel s in smlistByMonth) { if (s.breakfast == "1") { totalSelf++; } if (s.lunch == "1") { totalSelf++; } if (s.dinner == "1") { totalSelf++; } } //Calculate guest meals foreach (GuestMealsModel g in gmlistByMonth) { if (g.breakfast == "1") { totalGuest++; } if (g.lunch == "1") { totalGuest++; } if (g.dinner == "1") { totalGuest++; } } //Process subtotal details int subTotalMeals = totalSelf + totalGuest; int subTotalCost = int.Parse(pm.mealrate) * subTotalMeals; details = details + "<tr>" + "<td>" + u.fullname + "</td>" + "<td>" + subTotalMeals + "</td>" + "<td>" + subTotalCost + " Tk</td>" + "</tr>"; ViewBag.Details = details; //Process total cost info totalMeals = totalMeals + subTotalMeals; totalMealCost = totalMealCost + subTotalCost; serviceCharge = serviceCharge + int.Parse(pm.servicecharge); } //Process info totalCost = totalMealCost + serviceCharge; costInfo = costInfo + "<h3 class='text-danger'>Total Meal: <span class='text-success'>" + totalMeals + "</span></h3>" + "<h3 class='text-danger'>Meal Rate: <span class='text-success'>" + pm.mealrate + " Tk</span></h3>" + "<h3 class='text-danger'>Total Meal Cost: <span class='text-success'>" + totalMealCost + " Tk</span></h3>" + "<h3 class='text-danger'>Service Charge: <span class='text-success'>" + serviceCharge + " Tk</span></h3><hr />" + "<h3 class='text-danger'>Total Cost: <span class='text-success'>" + totalCost + " Tk</span></h3>"; ViewBag.CostInfo = costInfo; ViewBag.Showing = showing; } ViewBag.ReportResponse = response; }
private void processReport(string month, string year) { //Get all meals string response = ""; List <SelfMealsModel> smList = new List <SelfMealsModel>(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); SelfMealsModel smm = new SelfMealsModel(); GuestMealsModel gmm = new GuestMealsModel(); UserSessionModel usm = (UserSessionModel)Session["user"]; smm.memberId = usm.userid; gmm.memberId = usm.userid; foreach (SelfMealsModel sm in smm.getAllMealByMemberId()) { smList.Add(sm); } foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberId()) { gmList.Add(gm); } //Get preferences PreferencesModel pm = new PreferencesModel(); pm.getPrefrences(); if (smm.response == "500" || gmm.response == "500" || pm.response == "500") { response = "e"; } else { response = "s"; string showing = ""; string mealInfo = ""; string costInfo = ""; string details = ""; bool isValid = false; List <SelfMealsModel> smlistByMonth = new List <SelfMealsModel>(); List <GuestMealsModel> gmlistByMonth = new List <GuestMealsModel>(); //Check for valid date input string date = year + "-" + month + "-01"; DateTime dt2; if (DateTime.TryParse(date, out dt2)) { isValid = true; int inM = (int)dt2.Month; int inY = (int)dt2.Year; month = inM.ToString(); year = inY.ToString(); } else { isValid = false; } //List by month if (isValid) { showing = getMonth(month) + ", " + year; //Get self list by month foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } else { //Get list by current month showing = "Current Month"; month = getCurrentMonth(); year = getCurrentYear(); foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } //Get totals int totalSelf = 0; int totalGuest = 0; foreach (SelfMealsModel s in smlistByMonth) { int countB = 0; int countL = 0; int countD = 0; int subTotal = 0; int selfB = 0; int selfL = 0; int selfD = 0; if (s.breakfast == "1") { selfB++; } if (s.lunch == "1") { selfL++; } if (s.dinner == "1") { selfD++; } totalSelf = totalSelf + selfB + selfL + selfD; subTotal = subTotal + selfB + selfL + selfD; countB = countB + selfB; countL = countL + selfL; countD = countD + selfD; //Calculate guest meals string d = s.date; foreach (GuestMealsModel g in gmlistByMonth) { int guestB = 0; int guestL = 0; int guestD = 0; if (g.date == d) { if (g.breakfast == "1") { guestB++; } if (g.lunch == "1") { guestL++; } if (g.dinner == "1") { guestD++; } totalGuest = totalGuest + guestB + guestL + guestD; subTotal = subTotal + guestB + guestL + guestD; countB = countB + guestB; countL = countL + guestL; countD = countD + guestD; } } details = details + "<tr>" + "<td>" + d + "</td>" + "<td>" + countB + "</td>" + "<td>" + countL + "</td>" + "<td>" + countD + "</td>" + "<td>" + subTotal + "</td>" + "</tr>"; } //Generate results int totalMeal = totalSelf + totalGuest; mealInfo = "<p><b>Total Meal: <span class='text-success'>" + totalMeal + "</span></b></p>" + "<p><b>Self: <span class='text-success'>" + totalSelf + "</span></b></p>" + "<p><b>Guest: <span class='text-success'>" + totalGuest + "</span></b></p>"; int mealRate = int.Parse(pm.mealrate.Trim()); int serviceCharge = int.Parse(pm.servicecharge.Trim()); int totalMealCost = totalMeal * mealRate; int totalCost = totalMealCost + serviceCharge; costInfo = "<p><b>Meal rate: <span class='text-success'>" + pm.mealrate + " Tk/person</span></b></p>" + "<p><b>Meal cost: <span class='text-success'>" + totalMealCost + " Tk</span></b></p>" + "<p><b>Service charge: <span class='text-success'>" + pm.servicecharge + " Tk/person</span></b></p>" + "<p><b>Total cost: <span class='text-success'>" + totalCost + " Tk</span></b></p>"; ViewBag.Showing = showing; ViewBag.CostInfo = costInfo; ViewBag.Info = mealInfo; ViewBag.Details = details; } ViewBag.ReportResponse = response; }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> static void Main([NotNull][ItemNotNull] string [] args) { var programName = Process.GetCurrentProcess( ).ProcessName; if (args.Length == 1) { var fileName = args [0]; var fileInfo = new FileInfo(fileName); if (!fileInfo.Exists) { Console.WriteLine($"File '{fileInfo.FullName} does not exist"); } var preferencesModel = new PreferencesModel( ); PreferencesHelpers.Load(preferencesModel, fileInfo); var byGender = preferencesModel.ByGenderLastName( ); WriteRecords("By gender, then last name ascending", byGender); var byBirthDate = preferencesModel.ByBirthDate( ); WriteRecords("By birth date", byBirthDate); var byLastNameDescending = preferencesModel.ByLastNameDescending( ); WriteRecords("By last name descending", byLastNameDescending); var byName = preferencesModel.ByName( ); WriteRecords("By name", byName); } else if (args.Length == 2) { if (!int.TryParse(args [1], out var recordsToGenerate)) { throw new InvalidOperationException( ); } var fileName = args [0]; var fileInfo = new FileInfo(fileName); var format = fileInfo.Extension.ToUpperInvariant( ); if (fileInfo.Exists) { Console.WriteLine($"File '{fileInfo.FullName} already exists, you must remove it manually"); } var randomRecords = PreferencesHelpers.GenerateRandomRecords(recordsToGenerate, new Random( ), 7); using (var writer = new StreamWriter(fileInfo.FullName, false)) { var delimiterChar = PreferencesHelpers.AssociatedDelimiter(fileInfo); var delimiterString = delimiterChar.ToString( ); randomRecords.ForEach(r => { var strings = new [] { r.LastName, r.FirstName, r.Gender, r.FavoriteColor, r.DateOfBirth }.ToList( ); var line = string.Join(delimiterString, strings); writer.WriteLine(line); }); } } else { WriteUsageInfo( ); } }
public void DefaultConstructor( ) { var actual = new PreferencesModel( ); Assert.NotNull(actual); }
public static void Test_that_ordering_is_correct( ) { var randomProvider = new Random( ); var person1 = PreferencesHelpers.GenerateRandomRecord(randomProvider); var person1A = new PersonColorPreferenceModel( ).PopulateFrom(person1); person1A.LastName = "person1A"; var person2 = PreferencesHelpers.GenerateRandomRecord(randomProvider); var person3 = PreferencesHelpers.GenerateRandomRecord(randomProvider); var person3A = new PersonColorPreferenceModel( ).PopulateFrom(person3); person3A.LastName = "person3A"; var newRecords = new List <PersonColorPreferenceModel> { person1, PreferencesHelpers.GenerateRandomRecord(randomProvider), person1, PreferencesHelpers.GenerateRandomRecord(randomProvider), person2, PreferencesHelpers.GenerateRandomRecord(randomProvider), person2, PreferencesHelpers.GenerateRandomRecord(randomProvider), PreferencesHelpers.GenerateRandomRecord(randomProvider), person3, PreferencesHelpers.GenerateRandomRecord(randomProvider), person3 }.ToSafeList( ); var model = new PreferencesModel( ); model.Add(newRecords); var added = model.PersonColorPreferences.ToSafeList( ); var byBirthDate = model.ByBirthDate( ).ToSafeList( ); var byGenderLastName = model.ByGenderLastName( ).ToSafeList( ); var byLastNameDescending = model.ByLastNameDescending( ).ToSafeList( ); var byName = model.ByName( ).ToSafeList( ); added.Aggregate((arg1, arg2) => { Assert.True(arg1.Id < arg2.Id); return(arg2); }); byBirthDate.Aggregate((arg1, arg2) => { Assert.True(arg1.DateTimeBirth <= arg2.DateTimeBirth); return(arg2); }); byGenderLastName.Aggregate((arg1, arg2) => { var order = string.Compare(arg1.Gender, arg2.Gender, StringComparison.InvariantCulture); Assert.True(order <= 0); if (order == 0) { var order2 = string.Compare(arg1.LastNameUpper, arg2.LastNameUpper, StringComparison.InvariantCulture); Assert.True(order2 <= 0); } return(arg2); }); byLastNameDescending.Aggregate((arg1, arg2) => { Assert.True(string.Compare(arg1.LastNameUpper, arg2.LastNameUpper, StringComparison.InvariantCulture) >= 0); return(arg2); }); byName.Aggregate((arg1, arg2) => { var order = string.Compare(arg1.LastNameUpper, arg2.LastNameUpper, StringComparison.InvariantCulture); Assert.True(order <= 0); if (order == 0) { var order2 = string.Compare(arg1.FirstNameUpper, arg2.FirstNameUpper, StringComparison.InvariantCulture); Assert.True(order2 <= 0); } return(arg2); }); }
public PreferencesModelEventArgs(int eventId, PreferencesModel preferences) : base(eventId) { Preferences = preferences; }
public UpdatePreferencesCommand(PreferencesChangeEventArgs args, PreferencesModel preferences) { this.args = args; this.preferences = preferences; }
public LoadPreferencesCommand(PreferencesModel preferences) { this.preferences = preferences; }
public void RaiseOnPreferencesSaved(PreferencesModel preferences) { Logger.GetInstance().Debug("RaiseOnPreferencesSaved() >>"); OnPreferecesSaved(preferences); Logger.GetInstance().Debug("<< RaiseOnPreferencesSaved()"); }