public Category(CategoryEnum category) { Faces = new ObservableCollection <Face>(); this.Cat = category; string cat = category.ToString(); if (cat == "not_determined") { this.Gender = null; this.AgeFrom = -1; this.AgeTo = -1; } else { if (cat[0] == 'M') { this.Gender = "Male"; } else if (cat[0] == 'F') { this.Gender = "Female"; } int startIndex = cat.IndexOf("x") + ("x").Length; int endIndex = cat.IndexOf("_"); this.AgeFrom = int.Parse(cat.Substring(startIndex, endIndex - startIndex)); startIndex = cat.IndexOf("_") + ("_").Length; this.AgeTo = int.Parse(cat.Substring(startIndex, cat.Length - startIndex)); } }
protected Need GetExistingNeed(int churchID, CategoryEnum category, int submittedByID, string name, string description, string postalCode, DateTime requiredDate, int helpersNeeded) { Need need = null; try { need = Model.New<Need>(); need.ChurchID = churchID; need.CategoryID = (int)category; need.SubmittedByID = submittedByID; need.Name = name; need.Description = description; need.PostalCode = postalCode; need.RequiredDate = requiredDate; need.NeedStatusID = 1; need.HelpersNeeded = helpersNeeded; need.SetDataContext(GetNewDataContext()); need.Save(); // We have to change the EntityState back to NotSet or else all Save operations will think we're always inserting. need.EntityState = EntityStateEnum.NotSet; } catch (Exception ex) { Assert.IsTrue(false, "Failed to create existing Need in setup - " + ex.Message); } return need; }
public async Task GetRaitings(CategoryEnum category) { if (initializedRait == true) { return; } IsBusy = true; IEnumerable <Raiting> raitings = await quizService.GetRaiting(); while (Raitings.Any()) { Raitings.RemoveAt(Quizzes.Count - 1); } // добавляем загруженные данные foreach (Raiting raiting in raitings) { if (raiting.Category == category) { Raitings.Add(raiting); } } List <Raiting> tmp = Raitings.ToList(); tmp.Sort((x, y) => x.Points.CompareTo(y.Points)); tmp.Reverse(); Raitings = new ObservableCollection <Raiting>(tmp); IsBusy = false; initializedRait = true; }
public void _Return_Correctly(CategoryEnum categoryEnum) { //Arrange var category = new Category(); category.Name = categoryEnum; var categoryList = new List <Category>() { category, }.AsQueryable(); var mockedCategoryRepository = new Mock <IRepository <Category> >(); mockedCategoryRepository.Setup(r => r.GetAll).Returns(categoryList); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedCategoryFactory = new Mock <ICategoryFactory>(); var categoryService = new CategoryService(mockedCategoryRepository.Object, mockedUnitOfWork.Object, mockedCategoryFactory.Object); //Act var res = categoryService.GetAll(); //Assert CollectionAssert.AreEqual(categoryList, res); }
public void _Call_DateTimeProvider_GetCurrentDate( string userId, string title, string text, string coverPicture, CategoryEnum categoryEnum) { //Arrange var mockedPostRepository = new Mock <IRepository <Post> >(); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act postService.CreatePost(userId, title, text, coverPicture, categoryEnum); //Assert mockedDateTimeProvider.Verify(r => r.GetCurrentDate(), Times.Once); }
public Book(string title, string author, DateTime pubDate, CategoryEnum category) { Title = title; Author = author; Category = category; PubDate = pubDate; }
public Recipe GetRecipeById(string recipeId) { Recipe recipe = new Recipe(); if (Connection.State == ConnectionState.Closed) { Connection.Open(); } string sql = "SELECT * FROM recipes WHERE id='" + recipeId + "'"; MySqlCommand cmd = new MySqlCommand(sql, Connection); MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { recipe.RecipeId = dataReader["id"].ToString(); recipe.Name = dataReader["name"].ToString(); CategoryEnum category = (CategoryEnum)Enum.Parse(typeof(CategoryEnum), dataReader["category"].ToString(), true); recipe.Category = category; } //close Data Reader dataReader.Close(); return(recipe); }
private void Button_Clicked(object sender, EventArgs e) { Book book = new Book { AuthorName = AuthorPick.SelectedItem.ToString(), PageNumber = Convert.ToInt32(PageNumber.Text), PublishDate = PublishDate.Date }; book.BookName = BookName.Text; CategoryEnum category = (CategoryEnum)Enum.Parse(typeof(CategoryEnum), CategoryPick.SelectedItem.ToString().Replace(" ", "")); PublishersEnum publishers = (PublishersEnum)Enum.Parse(typeof(PublishersEnum), PublishPick.SelectedItem.ToString().Replace(" ", "")); book.Category = category; book.Publishers = publishers; book.BookPhoto = BookPhoto.Text; int addingbook = bookDataAccess.BookInsert(book); if (addingbook > 0) { DisplayAlert("ADD", "Book was add", "OK"); BookName.Text = ""; AuthorPick.SelectedItem = null; PublishDate.Date = DateTime.Now; PublishPick.SelectedItem = null; CategoryPick.SelectedItem = null; } else { DisplayAlert("ADD", "Book wasn't add", "OK"); } }
/// <summary> /// 更新訊息 /// </summary> /// <param name="news">新聞</param> public void Update(CategoryEnum category) { if (category == this._registeredCategory) { Console.WriteLine($"{this._readerName} 訂閱的新聞類型:{this._registeredCategory}有新的新聞"); } }
/// <summary> /// 通知訂閱者 /// </summary> /// <param name="category">新聞類型</param> public void NotifyObservers(CategoryEnum category) { foreach (var observer in this._itsObservers) { observer.Update(category); } }
public List <TravelOffer> SelectOfferyByCategory(CategoryEnum category) { try { using (var con = new Model1Container()) { var list = (from offer in con.TravelOfferSet .Include("Category") .Include("ExtendedInformation") where offer.CategoryId == (int)category select offer).ToList(); if (list.Count <= 0) { throw new Exception("No top offer found"); } return(list); } } catch (Exception) { return(new List <TravelOffer>() { CreateDefaultObject() }); } }
/// <summary> /// /// </summary> /// <param name="readerName">訂閱者</param> /// <param name="category">訂閱類型</param> public Reader(string readerName, CategoryEnum category) { this._readerName = readerName; this._registeredCategory = category; this.RegisterMessage(readerName, category); }
/// <summary> /// Downloads the relevant files from the server /// </summary> /// <param name="category">POI Category</param> /// <returns>Downloaded Data</returns> private static byte[] Download(CategoryEnum category) { string code = string.Empty; switch (category) { case CategoryEnum.NationalTrust: code = "nt"; break; case CategoryEnum.EnglishHeritage: code = "eh"; break; case CategoryEnum.HistoricHouses: code = "hh"; break; case CategoryEnum.HistoricScotland: code = "hs"; break; case CategoryEnum.NationalTrustScotland: code = "ns"; break; } WebClient client = new WebClient(); client.Headers.Add("Referer", $"https://www.poigraves.uk/pages/page{code}.php"); client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; return(client.DownloadData($"https://www.poigraves.uk/downloads/{code}garcsvdl.php")); }
public Room(int number, CategoryEnum category, decimal payByDay, int placeCount) { Number = number; Category = category; PayByDay = payByDay; PlaceCount = placeCount; }
public void _Call_CategoryService_GetCategoryByName( string userId, string title, string text, string coverPicture, CategoryEnum categoryEnum) { //Arrange var mockedNewsRepository = new Mock <IRepository <News> >(); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedNewsFactory = new Mock <INewsFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var newsService = new NewsService( mockedNewsRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedNewsFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act newsService.CreateNews(userId, title, text, coverPicture, categoryEnum); //Assert mockedCategoryService.Verify(c => c.GetCategoryByName(categoryEnum), Times.Once); }
public Category(string text, string name, string desc) { Text = text; Name = name; Description = desc; Value = CategoryEnum.None; }
public bool DeleteTriggerMaintenance_ByMaintenanceValue(DBSetting dbSetting, CategoryEnum category, ActionTypeEnum actionType, string maintenanceValue) { var TriggerMaintenanceList = TriggerMaintenanceRepo.Instance.GetTriggerMaintenance_ByMaintenanceValue(dbSetting, category, actionType, maintenanceValue.Replace("'", "''")); var responseModel = new DBResponseModel(); if (TriggerMaintenanceList.Rows.Count != 0) { //Delete the record responseModel = TriggerMaintenanceRepo.Instance.DeleteTriggerMaintenance_ByMaintenanceValue(dbSetting, category, maintenanceValue); if (responseModel.Status == DBStatusCodeEnum.Success) { return(true); } else { // fail, insert into log return(false); } } else { return(true); } }
public LogMessage(string context, CategoryEnum category, string text, Exception exception) { _emitter = context; _category = category; _text = text; _exception = exception; }
/// <summary> /// Initializes a new instance of the <see cref="PostUniverseNames200Ok" /> class. /// </summary> /// <param name="Category">category string (required).</param> /// <param name="Id">id integer (required).</param> /// <param name="Name">name string (required).</param> public PostUniverseNames200Ok(CategoryEnum Category = default(CategoryEnum), int?Id = default(int?), string Name = default(string)) { // to ensure "Category" is required (not null) if (Category == null) { throw new InvalidDataException("Category is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Category = Category; } // to ensure "Id" is required (not null) if (Id == null) { throw new InvalidDataException("Id is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Id = Id; } // to ensure "Name" is required (not null) if (Name == null) { throw new InvalidDataException("Name is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Name = Name; } }
public Category(string text, string name, string desc, CategoryEnum value) { Text = text; Name = name; Description = desc; Value = value; }
//[InlineData("Sraatta", "Dupa, dupa dupa dupa.", "24.01.2019 12:35:25", PriorityEnum.Low, true, CategoryEnum.Shopping, null)] //[InlineData("Sraatta", "Dupa, dupa dupa dupa.", "24.01.2019 12:35:25", PriorityEnum.Medium, true, CategoryEnum.Shopping, null)] //[MemberData(nameof(GetDataForTest))] public void InvalidPriorityRangeTest(string name, string desc, string createdAt, PriorityEnum prio, bool isDone, CategoryEnum cate, ICollection <Comment> comments) { DateTime createdAtDate = DateTime.Parse(createdAt); PriorityEnum priority = prio; CategoryEnum category = cate; var obj = new TaskModel() { Name = name, ShortDescription = desc, CreatedAt = createdAtDate, Priority = priority, IsDone = isDone, Category = category, Comments = comments ?? new List <Comment>() }; var objConverted = TaskModelConverter.ConvertTaskToShowAllView(obj); Assert.Equal(obj.Name, objConverted.Name); Assert.Equal(obj.ShortDescription, objConverted.ShortDescription); Assert.Equal(priority, objConverted.Priority); Assert.Equal(obj.Comments.Count, objConverted.NumberOfComments); }
public void CanUseRepository(CategoryEnum categoryEnum) { Mock <IStoreRepository> mock = new Mock <IStoreRepository>(); mock.Setup(m => m.Products).Returns(( new Product[] { new Product { Name = "Test1", Description = "Desc for Test1", Category = CategoryEnum.Tutu.ToString() }, new Product { Name = "Test2", Description = "Desc for Test2", Category = CategoryEnum.Fairy.ToString() } } ).AsQueryable <Product>()); // Act StoreController storeController = new StoreController(mock.Object, new Cart()); ProductListViewModel productListViewModels = storeController.Index(categoryEnum.ToString()) .ViewData.Model as ProductListViewModel; // assert Product[] productArray = productListViewModels?.Products?.ToArray(); Assert.AreEqual(productArray?.Length, 2); Assert.AreEqual(productArray[0]?.Category, CategoryEnum.Tutu.ToString()); Assert.AreEqual(productArray[1]?.Name, "Test2"); }
/// <summary> /// Initializes a new instance of the <see cref="PostUniverseNames200Ok" /> class. /// </summary> /// <param name="category">category string (required).</param> /// <param name="id">id integer (required).</param> /// <param name="name">name string (required).</param> public PostUniverseNames200Ok(CategoryEnum category = default(CategoryEnum), int?id = default(int?), string name = default(string)) { // to ensure "category" is required (not null) if (category == null) { throw new InvalidDataException("category is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Category = category; } // to ensure "id" is required (not null) if (id == null) { throw new InvalidDataException("id is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Id = id; } // to ensure "name" is required (not null) if (name == null) { throw new InvalidDataException("name is a required property for PostUniverseNames200Ok and cannot be null"); } else { this.Name = name; } }
// use as setter, also check for validation public async Task <Product> PutUpForAuction(string userId, string name, CategoryEnum category, decimal startingPrice, DateTime endingTime, string description, byte[] productImage) { //throw new NotImplementedException(); var user = _lemonContext.Users .FirstOrDefault(u => (u.Id == userId)); var productName = _lemonContext.Products .FirstOrDefault(u => (u.Name == name)); if (user == null) { throw new Exceptions.LemonNotFoundException($"No such userId: ${userId}"); } // else if(category == null) // { // throw new Exceptions.LemonInvalidException($"Category selected is null"); // } // else if(productName != null) // { // throw new ArgumentException($"Product name is already taken: ${name}"); // } else if (name == null) { throw new Exceptions.LemonInvalidException($"Product name is null"); } else if (startingPrice == 0) // 0 is null in this case { throw new Exceptions.LemonInvalidException($"Starting price must be non zero"); } else if (endingTime == null) { throw new Exceptions.LemonInvalidException($"Ending time is null"); } else if (description == null) { throw new Exceptions.LemonInvalidException($"Description is null"); } else if (productImage == null) { throw new Exceptions.LemonInvalidException($"Product image is null"); } else { var product = new Product { Name = name, Category = category.ToString(), Seller = user, Description = description, MinimumBid = startingPrice, BiddingStartTime = DateTime.UtcNow, BiddingEndTime = endingTime, Image = productImage }; _lemonContext.Products.Add(product); await _lemonContext.SaveChangesAsync(); return(product); } }
private void ListLevelsSelectedIndexChanged(object sender, EventArgs e) { if (this.listLevels.SelectedItems.Count == 1) { this.categorySelected = CategoryEnum.Level; this.actorSelected = Actors.StaticActors.Select(x => x.Value).FirstOrDefault(y => y.Name == this.listLevels.SelectedItems[0].Text); } }
private static List <Product> AddCollection(List <Product> products, CategoryEnum categoryEnum) { foreach (var product in products) { product.CategoryEnum = categoryEnum; } return(products); }
public bool Equals(CategoryEnum obj) { if ((object)obj == null) { return(false); } return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value)); }
public IEnumerable <Article> GetArticlesByCategory(CategoryEnum id) { var articles = db.Articles .Where(a => a.Category == id) .OrderBy(a => a.Published); return(articles); }
private static List<Product> AddCollection(List<Product> products, CategoryEnum categoryEnum) { foreach (var product in products) { product.CategoryEnum = categoryEnum; } return products; }
private void OnCategoryChanged(CategoryEnum category) { m_Button.spriteState = data?.category == category ? m_Style.selectedButtonSprites : m_Style.unselectedButtonSprites; m_Button.image.sprite = m_Button.spriteState.highlightedSprite; }
private ChooseCategoryModel CreateButtonGray(CategoryEnum category) { return(new ChooseCategoryModel { ChooseAnswerCommand = new RelayCommand <Button>(CategoryChosenAsync), TextButton = category }); }
public static void VerifyCropVariety(List <Product> catalogProducts, List <Crop> catalogCrops, string expectedDescription, string expectedGuid, CategoryEnum expectedCategoryEnum, string expectedCrop) { var product = VerifyProduct(catalogProducts, expectedDescription, expectedGuid, expectedCategoryEnum, typeof(CropVarietyProduct)); var crop = catalogCrops.Find(x => x.Name == expectedCrop); Assert.AreEqual(crop.Id.ReferenceId, ((CropVarietyProduct)product).CropId); }
public List<TravelOffer> SelectOfferyByCategory(CategoryEnum category) { try { using (var con = new Model1Container()) { var list = (from offer in con.TravelOfferSet .Include("Category") .Include("ExtendedInformation") where offer.CategoryId == (int) category select offer).ToList(); if (list.Count <= 0) throw new Exception("No top offer found"); return list; } } catch (Exception) { return new List<TravelOffer>() { CreateDefaultObject() }; } }
public Issue(User reportedBy, PriorityEnum priority, Project project, CategoryEnum category, Component component, ProductVersion version, Resolution resolution, string summary, string description, string environment, User assignedTo, DateTime dueDate, SortedSetAny<Attachment> attachments, StatusEnum status = StatusEnum.Open) { if (attachments != null) this.attachments = attachments; else this.attachments = new SortedSetAny<Attachment>(); this.reportedBy = reportedBy; this.project = project; this.component = component; affectedComponentSet = new SortedSetAny<Component>(1); if (component != null) affectedComponentSet.Add(component); affectedVersionSet = new SortedSetAny<ProductVersion>(1); if (version != null) affectedVersionSet.Add(version); voteSet = new SortedSetAny<Vote>(1); relatedIssueSet = new SortedSetAny<Issue>(1); fixedInVersionSet = new SortedSetAny<ProductVersion>(1); subTaskSet = new SortedSetAny<SubTask>(1); labelSet = new SortedSetAny<ProductLabel>(1); this.version = version; this.summary = summary; this.description = description; this.environment = environment; this.category = category; this.priority = priority; fixResolution = resolution; dateTimeCreated = DateTime.Now; dateTimeLastUpdated = dateTimeCreated; fixmessage = null; lastUpdatedBy = reportedBy; this.dueDate = dueDate; this.status = status; this.AssignedTo = assignedTo; subscribers = null; // to do testCase = null;// to do }
public Issue(User reportedBy, PriorityEnum priority, Project project, CategoryEnum category, Component component, ProductVersion version, Resolution resolution, string summary, string description, string environment, User assignedTo, DateTime dueDate, SortedSetAny<Attachment> attachments, StatusEnum status = StatusEnum.Open) { if (attachments != null) m_attachments = attachments; else m_attachments = new SortedSetAny<Attachment>(); m_reportedBy = reportedBy; m_project = project; m_component = component; m_affectedComponentSet = new SortedSetAny<Component>(1); if (component != null) m_affectedComponentSet.Add(component); m_affectedVersionSet = new SortedSetAny<ProductVersion>(1); if (version != null) m_affectedVersionSet.Add(version); m_voteSet = new SortedSetAny<Vote>(1); m_relatedIssueSet = new SortedSetAny<Issue>(1); m_fixedInVersionSet = new SortedSetAny<ProductVersion>(1); m_subTaskSet = new SortedSetAny<SubTask>(1); m_labelSet = new SortedSetAny<ProductLabel>(1); m_version = version; m_summary = summary; m_description = description; m_environment = environment; m_category = category; m_priority = priority; m_fixResolution = resolution; m_dateTimeCreated = DateTime.Now; m_dateTimeLastUpdated = m_dateTimeCreated; m_fixmessage = null; m_lastUpdatedBy = reportedBy; m_dueDate = dueDate; m_status = status; AssignedTo = assignedTo; m_subscribers = null; // to do m_testCase = null;// to do }
ActionResult BrowseByCategory(CategoryEnum item) { var qry = from x in Product.Queryable where x.IsActive && x.Category == item select new EquipmentItem { Id = x.Id, MakeName = x.MakeName, Model = x.Model, Price = x.Price }; return Browse (item.GetDisplayName (), qry.ToList ()); }