public void test_browse()
        {
            var controller = new StoreController(new CategoryBLL(new CategoryStub()), new ProductBLL(new ProductStub()));

            var temp = new List<Product>();
            var prod = new Product()
            {
                ProductId = 1,
                CategoryId = 1,
                Name = "LOLOL",
                Price = 123,
                ProductPicUrl = "/Content/Images/placeholder.gif"
            };
            temp.Add(prod);
            temp.Add(prod);
            temp.Add(prod);
            var cat = new Category()
            {
                CategoryId = 1,
                Name = "HelloMon",
                Products = temp
            };

            var result = (ViewResult)controller.Browse("HelloMon");
            var resultCat = (Category)result.Model;

            Assert.AreEqual(result.ViewName, "");
            Assert.AreEqual(resultCat.Name, cat.Name);
        }
        public IHttpActionResult CreateCategory(CategoryBindingModel categoryBinding)
        {
            if (categoryBinding == null)
            {
                return this.BadRequest("Input is empty.");
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            if (this.Data.Categories.Read().Any(c => c.Name == categoryBinding.Name))
            {
                return this.BadRequest("Duplicate category name");
            }

            var category = new Category { Name = categoryBinding.Name };

            this.Data.Categories.Create(category);
            this.Data.SaveChanges();

            var categoryView = new CategoryViewModel
                                   {
                                       Id = category.Id, 
                                       Name = category.Name
                                   };

            return this.Ok(categoryView);
        }
Esempio n. 3
0
        /// <summary>
        /// Deletes a category from the database
        /// </summary>
        /// <param name="category">category to be removed</param>
        public override void DeleteCategory(Category category)
        {
            List<Category> categories = Category.Categories;
            categories.Remove(category);

            string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString;
            string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName;
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);

            using (DbConnection conn = provider.CreateConnection())
            {
                conn.ConnectionString = connString;
                conn.Open();
                using (DbCommand cmd = conn.CreateCommand())
                {
                    string sqlQuery = "DELETE FROM " + tablePrefix + "PostCategory " +
                        "WHERE CategoryID = " + parmPrefix + "catid;" +
                        "DELETE FROM " + tablePrefix + "Categories " +
                        "WHERE CategoryID = " + parmPrefix + "catid";
                    cmd.CommandText = sqlQuery;
                    cmd.CommandType = CommandType.Text;

                    DbParameter dpID = provider.CreateParameter();
                    dpID.ParameterName = parmPrefix + "catid";
                    dpID.Value = category.Id.ToString();
                    cmd.Parameters.Add(dpID);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Esempio n. 4
0
        public LocalPlayer(World world, Vector2 position, Category collisionCat, float scale, float limbStrength, float limbDefense, bool evilSkin, Color color, PlayerIndex player)
            : base(world, position, collisionCat, scale, limbStrength, limbDefense, evilSkin, color)
        {
            this.player = player;
            punchBtnPressed = punchKeyPressed = false;
            kickBtnPressed = kickKeyPressed = false;
            shootBtnPressed = shootKeyPressed = false;
            trapBtnPressed = trapKeyPressed = false;
            usesKeyboard = !GamePad.GetState(player).IsConnected;
            lastShootAngle = 0f;

            jumpBtn = Buttons.A;
            rightBtn = Buttons.LeftThumbstickRight;
            leftBtn = Buttons.LeftThumbstickLeft;
            crouchBtn = Buttons.LeftTrigger;
            punchBtn = Buttons.X;
            kickBtn = Buttons.B;
            shootBtn = Buttons.RightTrigger;
            trapBtn = Buttons.Y;

            upKey = Keys.W;
            rightKey = Keys.D;
            leftKey = Keys.A;
            downKey = Keys.S;
            trapKey = Keys.T;
        }
        public override int DiscoverSubCategories(Category parentCategory)
        {
            string url = ((RssLink)parentCategory).Url;
            bool isAZ = !url.Contains("/tv");
            if (isAZ)
                return SubcatFromAZ((RssLink)parentCategory);
            parentCategory.SubCategories = new List<Category>();
            string catUrl = ((RssLink)parentCategory).Url + "/kaikki.json?from=0&to=24";
            string webData = GetWebData(catUrl, forceUTF8: true);
            JToken j = JToken.Parse(webData);
            JArray orders = j["filters"]["jarjestys"] as JArray;
            parentCategory.SubCategories = new List<Category>();
            foreach (JToken order in orders)
            {
                string orderBy = order.Value<string>("key");
                RssLink subcat = new RssLink()
                {
                    Name = orderBy,
                    Url = ((RssLink)parentCategory).Url + "/kaikki.json?jarjestys=" + orderBy + '&',
                    ParentCategory = parentCategory,
                };
                parentCategory.SubCategories.Add(subcat);
            }
            parentCategory.SubCategoriesDiscovered = true;

            return parentCategory.SubCategories.Count;
        }
 public void Log(string message, Category category, Priority priority)
 {
     _bootLogger.Log(String.Format("{0}|{1}: {2}",
         FormatString(category.ToString(), 9),
         FormatString(priority.ToString(), 6),
         message));
 }
Esempio n. 7
0
        public Category[] GetAllCategories()
        {
            List<Category> myCategories = new List<Category>();
            SqlConnection myConn = new SqlConnection(connstring);
            myConn.Open();

                SqlCommand mySqlCommand = new SqlCommand("select * from Category", myConn);
                SqlDataReader reader = mySqlCommand.ExecuteReader();

            while (reader.Read())
            {
                Category myCategory = new Category();
                object id = reader["Id"];

                if (id != null)
                {
                    int categoryId = -1;
                    if (!int.TryParse(id.ToString(), out categoryId))
                    {
                        throw new Exception("Failed to parse Id of video.");
                    }
                    myCategory.Id = categoryId;
                }

                myCategory.Name = reader["Name"].ToString();

                myCategories.Add(myCategory);
            }

            myConn.Close();

            return myCategories.ToArray();
        }
        /// <summary>
        /// Deletes a category from the database
        /// </summary>
        /// <param name="category">
        /// category to be removed
        /// </param>
        public override void DeleteCategory(Category category)
        {
            var categories = Category.Categories;
            categories.Remove(category);

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("DELETE FROM {0}PostCategory WHERE CategoryID = {1}catid", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("catid"), category.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Categories WHERE CategoryID = {1}catid", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("catid"), category.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
Esempio n. 9
0
 public static List<Category> GetCategory()
 {
     List<Category> categoryList = new List<Category>();
     SqlConnection con = new SqlConnection(GetConnectionString());
     string sel = "SELECT Customer_id, first_name, last_name, street, city, state, zip "
         + "FROM Customers ORDER BY Customer_id desc";
     SqlCommand cmd = new SqlCommand(sel, con);
     con.Open();
     SqlDataReader dr =
         cmd.ExecuteReader(CommandBehavior.CloseConnection);
     Category category;
     while (dr.Read())
     {
         category = new Category();
         category.Customer_ID = dr["Customer_ID"].ToString();
         category.First_Name = dr["First_Name"].ToString();
         category.Last_Name = dr["Last_Name"].ToString();
         category.Street = dr["Street"].ToString();
         category.City = dr["City"].ToString();
         category.State = dr["State"].ToString();
         category.Zip = dr["Zip"].ToString();
         categoryList.Add(category);
     }
     dr.Close();
     return categoryList;
 }
        public VideoViewModel(VideoInfo videoInfo, Category category, string siteName, string utilName, bool isDetailsVideo)
            : base(Consts.KEY_NAME, isDetailsVideo ? ((DetailVideoInfo)videoInfo).Title2 : videoInfo.Title)
        {
            VideoInfo = videoInfo;
			Category = category;
			SiteName = siteName;
			SiteUtilName = utilName;
			IsDetailsVideo = isDetailsVideo;

            _titleProperty = new WProperty(typeof(string), videoInfo.Title);
            _title2Property = new WProperty(typeof(string), isDetailsVideo ? ((DetailVideoInfo)videoInfo).Title2 : string.Empty);
            _descriptionProperty = new WProperty(typeof(string), videoInfo.Description);
            _lengthProperty = new WProperty(typeof(string), videoInfo.Length);
			_airdateProperty = new WProperty(typeof(string), videoInfo.Airdate);
            _thumbnailImageProperty = new WProperty(typeof(string), videoInfo.ThumbnailImage);

			_contextMenuEntriesProperty = new WProperty(typeof(ItemsList), null);

			eventDelegator = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(PropertyChangedDelegator).Assembly.FullName, typeof(PropertyChangedDelegator).FullName) as PropertyChangedDelegator;
			eventDelegator.InvokeTarget = new PropertyChangedExecutor()
			{
				InvokeHandler = (s, e) =>
				{
					if (e.PropertyName == "ThumbnailImage") ThumbnailImage = (s as VideoInfo).ThumbnailImage;
					else if (e.PropertyName == "Length") Length = (s as VideoInfo).Length;
				}
			};
			VideoInfo.PropertyChanged += eventDelegator.EventDelegate;
        }
Esempio n. 11
0
        public void Should_Apply_DeletedOn_Field_After_Save()
        {
            // Can be any another entity type.
            var entity = new Category();
            entity.Name = "test name";

            DeleteCreatedEntityAndRunAssertionsInTransaction(
                entity,
                resultEntity =>
                    {
                        Assert.IsTrue(resultEntity.IsDeleted);
                        Assert.IsNotNullOrEmpty(resultEntity.DeletedByUser);
                        Assert.AreNotEqual(default(DateTime), resultEntity.DeletedOn);
                    },
                entityBeforeSave =>
                    {
                        Assert.IsFalse(entity.IsDeleted);
                        Assert.IsNullOrEmpty(entityBeforeSave.DeletedByUser);
                        Assert.AreEqual(default(DateTime?), entityBeforeSave.DeletedOn);
                    },
                entityAfterSave =>
                    {
                        Assert.IsTrue(entityAfterSave.IsDeleted);
                        Assert.IsNotNullOrEmpty(entityAfterSave.DeletedByUser);
                        Assert.AreNotEqual(default(DateTime), entityAfterSave.DeletedOn);
                    });
        }
Esempio n. 12
0
        public static void SetupData(ISession session)
        {
            using (ITransaction transaction = session.BeginTransaction())
            {
                var user = new User() { Username = "******" };

                session.Save(user);

                for (int i = 0; i < 10; i++)
                {
                    var blog = new Blog() { Name = String.Format("Blog{0}", i), User = user };

                    var category1 = new Category() { Blog = blog, Description = "Description1", HtmlUrl = "htmlurl1", RssUrl = "rssurl1" };
                    var category2 = new Category() { Blog = blog, Description = "Description2", HtmlUrl = "htmlurl2", RssUrl = "rssurl2" };
                    var category3 = new Category() { Blog = blog, Description = "Description3", HtmlUrl = "htmlurl3", RssUrl = "rssurl3" };

                    blog.AddCategory(category1);
                    blog.AddCategory(category2);
                    blog.AddCategory(category3);

                    session.Save(blog);

                    for (int j = 0; j < 1000; j++)
                    {
                        var post = new Post() { Date = DateTime.Now, Title = String.Format("Blog{0}Post{1}", i, j) };

                        post.Blog = blog;
                        session.Save(post);
                    }
                }
                transaction.Commit();

            }
        }
        /// <summary>
        /// Load the videos for the selected category - will only handle general category types
        /// </summary>
        /// <param name="parentCategory"></param>
        /// <returns></returns>
        public static List<VideoInfo> LoadGeneralVideos(Category parentCategory)
        {
            var doc = new XmlDocument();
            var result = new List<VideoInfo>();
            var path = "/brandLongFormInfo/allEpisodes/longFormEpisodeInfo"; // default the path for items without series

            doc.Load(parentCategory.CategoryInformationPage());

            if (!string.IsNullOrEmpty(parentCategory.SeriesId()))
            {
                path = "/brandLongFormInfo/allSeries/longFormSeriesInfo[seriesNumber='" + parentCategory.SeriesId() + "'] /episodes/longFormEpisodeInfo";
            }

            foreach (XmlNode node in doc.SelectNodes(path))
            {
                var item = new VideoInfo();
                item.Title = node.SelectSingleNodeText("title1") + (string.IsNullOrEmpty(node.SelectSingleNodeText("title2")) ? string.Empty : " - ") + node.SelectSingleNodeText("title2"); 
                item.Description = node.SelectSingleNodeText("synopsis");
                //item.ImageUrl = Properties.Resources._4OD_RootUrl + node.SelectSingleNodeText("pictureUrl");
                item.Thumb = node.SelectSingleNodeText("pictureUrl");

                DateTime airDate;

                if (DateTime.TryParse(node.SelectSingleNodeText("txTime"), out airDate))
                    item.Airdate = airDate.ToString("dd MMM yyyy");

                item.Other = doc.SelectSingleNodeText("/brandLongFormInfo/brandWst") + "~" + node.SelectSingleNodeText("requestId");
                result.Add(item);
            }

            return result;
        }
Esempio n. 14
0
 public static string GetCategoryPrefix(Category category)
 {
     var type = typeof(Category);
     var memInfo = type.GetMember(category.ToString());
     var attributes = memInfo[0].GetCustomAttributes(typeof(PrefixAttribute), false);
     return ((PrefixAttribute)attributes[0]).Prefix;
 }
        public override List<VideoInfo> GetVideos(Category category)
        {
            List<VideoInfo> tVideos = new List<VideoInfo>();
            string sUrl = (category as RssLink).Url;
            string sContent = GetWebData((category as RssLink).Url);

            JArray tArray = JArray.Parse(sContent );
            foreach (JObject obj in tArray) 
            {
                try 
                {
                    VideoInfo vid = new VideoInfo()
                    {
                        Thumb = (string)obj["MEDIA"]["IMAGES"]["PETIT"],
                        Title = (string)obj["INFOS"]["TITRAGE"]["TITRE"],
                        Description = (string)obj["INFOS"]["DESCRIPTION"],
                        Length = (string)obj["DURATION"],
                        VideoUrl = (string)obj["ID"],
                        StartTime = (string)obj["INFOS"]["DIFFUSION"]["DATE"]
                    };
                    tVideos.Add(vid);
                }
                catch { }
            }
            return tVideos;
        }
Esempio n. 16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int errCnt = 0;
        if (TextBox1.Text == "")
        {
            Label6.Text = "*";
            errCnt++;
        }
        if (TextBox4.Text == "")
        {
            Label7.Text = "*";
            errCnt++;
        }
        if (errCnt != 0) return;

        if (Session["CategoryList"] != null)
        {
            List<Category> list = (List<Category>)Session["CategoryList"];
            if (validateName(list, TextBox1.Text) == false)
            {
                Label6.Text = "exists";
                return;
            }

            Category cat = new Category("", DropDownList1.SelectedValue, TextBox1.Text, new List<string>(), Convert.ToInt32(TextBox4.Text));

            DropDownList1.Items.Add(cat.getCatrgoryName());
            DropDownList2.Items.Add(cat.getCatrgoryName());
            ListBox2.Items.Add(cat.getCatrgoryName());
            list.Add(cat);

            ListBox2_SelectedIndexChanged(null, null);
        }
    }
        /// <summary>
        /// Request that the categories get loaded - we do this and then populate the LoadedCategories property
        /// </summary>
        /// <returns></returns>
        public List<Category> LoadCategories(Category parentCategory = null)
        {
            var result = new List<Category>();
            if (parentCategory == null)
            {
                result.Add(new Category { Name = "Catch up", SubCategoriesDiscovered = false, HasSubCategories = true, Other = "C~a27eef2528673410VgnVCM100000255212ac____" });
                //result.Add(new Category { Name = "Live TV", SubCategoriesDiscovered = false, HasSubCategories = false, Other = "L~Live_TV" });
                result.Add(new Category { Name = "Sky Movies", SubCategoriesDiscovered = false, HasSubCategories = true, Other = "R~7fc1acce88d77410VgnVCM1000000b43150a____" });
                result.Add(new Category { Name = "TV Box Sets", SubCategoriesDiscovered = false, HasSubCategories = true, Other = "B~9bb07a0acc5a7410VgnVCM1000000b43150a____" });
            }
            else
            {
                switch (parentCategory.Type())
                { 
                    case SkyGoCategoryData.CategoryType.CatchUp:
                        LoadCatchupInformation(parentCategory);
                        break;
                    default:
                        LoadSubCategories(parentCategory, parentCategory.Type() != SkyGoCategoryData.CategoryType.CatchUpSubCategory);
                        break;
                }
            }

            return result;
        }
Esempio n. 18
0
 public override List<VideoInfo> GetVideos(Category category)
 {
   List<VideoInfo> videos = base.GetVideos(category);
   TMDB.BackgroundWorker worker = new TMDB.BackgroundWorker();
   worker.start(videos);
   return videos;
 }
Esempio n. 19
0
    public static ItemScript CreateItem(Category type, int id)
    {
        /*GameObject tmp = Instantiate(InventoryManager.Instance.itemObject);
        tmp.AddComponent<ItemScript>();
        ItemScript itemScript = tmp.GetComponent<ItemScript>();

        Destroy(tmp);*/
        ItemScript itemScript = new ItemScript();

        switch (type)
        {
            case Category.Equipment:
                itemScript.Item = InventoryManager.Instance.ItemContainer.Equipments.Find(x => x.Id == id);
                break;
            case Category.Weapon:
                itemScript.Item = InventoryManager.Instance.ItemContainer.Weapons.Find(x => x.Id == id);
                break;
            case Category.Consumable:
                itemScript.Item = InventoryManager.Instance.ItemContainer.Consumables.Find(x => x.Id == id);
                break;
            default:
                break;
        }

        return itemScript;
    }
		public void Log(string message, Category category, Priority priority)
		{
			LogLevel nLevel = null;

			switch (category)
			{
				case Category.Debug:
					nLevel = LogLevel.Debug;
					break;

				case Category.Exception:
					nLevel = LogLevel.Error;
					break;

				case Category.Info:
					nLevel = LogLevel.Info;
					break;

				case Category.Warn:
					nLevel = LogLevel.Warn;
					break;
			}

			_logger.Log(nLevel, message);

		}
        public IHttpActionResult PutCategory(int id, Category category)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != category.CategoryId)
            {
                return BadRequest();
            }

            db.Entry(category).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Esempio n. 22
0
 public JsonResult All(Category? category)
 {
     if (_highscoreService.IsValidCategory(category))
         return Json(_highscoreService.GetHighscores((Category)category),JsonRequestBehavior.AllowGet);
     else
         return Json(new { success = false },JsonRequestBehavior.AllowGet);
 }
Esempio n. 23
0
        /// <summary>
        /// Write a new log entry with the specified category and priority.
        /// </summary>
        /// <param name="message">Message body to log.</param>
        /// <param name="category">Category of the entry.</param>
        /// <param name="priority">The priority of the entry.</param>
        public void Log(string message, Category category, Priority priority)
        {
            string messageToLog = String.Format(CultureInfo.InvariantCulture, Resources.DefaultTextLoggerPattern, DateTime.Now,
                                                category.ToString().ToUpper(CultureInfo.InvariantCulture), message, priority.ToString());

            writer.WriteLine(messageToLog);
        }
 /// <summary>
 /// Constructs a FPE Body from the given list of vertices and density
 /// </summary>
 /// <param name="game"></param>
 /// <param name="world"></param>
 /// <param name="vertices">The collection of vertices in display units (pixels)</param>
 /// <param name="bodyType"></param>
 /// <param name="density"></param>
 public PhysicsGameEntity(Game game, World world, Category collisionCategory, Vertices vertices, BodyType bodyType, float density)
     : this(game,world,collisionCategory)
 {
     ConstructFromVertices(world,vertices,density);
     Body.BodyType = bodyType;
     Body.CollisionCategories = collisionCategory;
 }
Esempio n. 25
0
    protected void Page_Load(object sender, EventArgs e)
    {

        PostAroundServiceClient client = new PostAroundServiceClient();
        Category[] arrCategroies = client.GetListCategories();
        client.Close();

        List<Category> lstCategories = arrCategroies.ToList();

        Category firstCategory = new Category();
        firstCategory.ID = 0;
        firstCategory.Name = "Everything";
        firstCategory.Color = "#e3e3e3";
        lstCategories.Insert(0, firstCategory);


        rptCategoriesColumn1.ItemCreated += new RepeaterItemEventHandler(rptCategories_ItemCreated);

        rptCategoriesColumn1.DataSource = L10NCategories(lstCategories); //.Take(8);
        rptCategoriesColumn1.DataBind();

        //rptCategoriesColumn2.ItemCreated += new RepeaterItemEventHandler(rptCategories_ItemCreated);
        //rptCategoriesColumn2.DataSource = lstCategories.Skip(8).Take(8);
        //rptCategoriesColumn2.DataBind();
    }
        public CategoryContentDialog(Category category)
        {
            this.InitializeComponent();

            _category = category;
            txtCategoryName.Text = _category.c_caption;
        }
 public PhysicsGameEntity(Game game, World world, Category collisionCategory, Body body, Vector2 origin)
     : this(game,world,collisionCategory)
 {
     Body = body;
     Center = origin;
     Body.CollisionCategories = collisionCategory;
 }
Esempio n. 28
0
		public override int DiscoverDynamicCategories()
		{
			Settings.Categories.Clear();

			// load homepage
			var doc = GetWebData<HtmlDocument>(baseUrl);
			var json = JsonFromScriptBlock(doc.DocumentNode, "require('js/page/home')");

			// build categories for the themes
			Category categoriesCategory = new Category() { HasSubCategories = true, SubCategoriesDiscovered = true, Name = "Themen", SubCategories = new List<Category>() };
			foreach (var jCategory in json["categoriesVideos"] as JArray)
			{
				var categorySubNode = jCategory["category"];
				categoriesCategory.SubCategories.Add(new RssLink()
				{
					ParentCategory = categoriesCategory,
					EstimatedVideoCount = jCategory.Value<uint>("total_count"),
					Name = categorySubNode.Value<string>("name"),
					Description = categorySubNode.Value<string>("description"),
					Url = string.Format("{0}/videos?category={1}&page=1&limit=24&sort=newest", baseUrl, categorySubNode.Value<string>("code"))
				});
			}
			if (categoriesCategory.SubCategories.Count > 0) Settings.Categories.Add(categoriesCategory);

			// build categories for the shows
			Category showsCategory = new Category() { HasSubCategories = true, SubCategoriesDiscovered = true, Name = "Sendungen", SubCategories = new List<Category>() };
			foreach (var jCategory in json["clusters"] as JArray)
			{
				showsCategory.SubCategories.Add(new RssLink()
				{
					ParentCategory = showsCategory,
					Name = jCategory.Value<string>("title"),
					Description = jCategory.Value<string>("subtitle"),
					Url = string.Format("{0}/videos?cluster={1}&page=1&limit=24&sort=newest", baseUrl, jCategory.Value<string>("id"))
				});
			}
			if (showsCategory.SubCategories.Count > 0) Settings.Categories.Add(showsCategory);


			// build categories for the last 7 days
			Category dailyCategory = new Category() { HasSubCategories = true, SubCategoriesDiscovered = true, Name = "Letzte 7 Tage", SubCategories = new List<Category>() };
			for (int i = 0; i > -7; i--)
			{
				dailyCategory.SubCategories.Add(new RssLink()
				{
					ParentCategory = dailyCategory,
					Name = DateTime.Today.AddDays(i - 1).ToShortDateString(),
					Url = string.Format("{0}/videos?day={1}&page=1&limit=24&sort=newest", baseUrl, i)
				});
			}
			Settings.Categories.Add(dailyCategory);

			// build additional categories also found on homepage
			Settings.Categories.Add(new RssLink() { Name = "Neueste Videos", Url = string.Format("{0}/videos?page=1&limit=24&sort=newest", baseUrl) });
			Settings.Categories.Add(new RssLink() { Name = "Meistgesehen", Url = string.Format("{0}/videos?page=1&limit=24&sort=most_viewed", baseUrl) });
			Settings.Categories.Add(new RssLink() { Name = "Letzte Chance", Url = string.Format("{0}/videos?page=1&limit=24&sort=next_expiring", baseUrl) });

			Settings.DynamicCategoriesDiscovered = true;
			return Settings.Categories.Count;
		}
Esempio n. 29
0
 public override List<VideoInfo> GetVideos(Category category)
 {
     if (true.Equals(category.Other)) //videos in serwisy informacyjne
     {
         string sav = videoListRegExFormatString;
         videoListRegExFormatString = "{0}";
         var res = base.GetVideos(category);
         videoListRegExFormatString = sav;
         return res;
     }
     string webData = GetWebData(((RssLink)category).Url);
     JObject contentData = JObject.Parse(webData);
     if (contentData != null)
     {
         JArray items = contentData["items"] as JArray;
         if (items != null)
         {
             List<VideoInfo> result = new List<VideoInfo>();
             foreach (JToken item in items)
                 if (!item.Value<bool>("payable") && item.Value<int>("play_mode") == 1)
                 {
                     VideoInfo video = new VideoInfo();
                     video.Title = item.Value<string>("title");
                     video.VideoUrl = String.Format(videoListRegExFormatString, item.Value<string>("_id"));
                     video.Description = item.Value<string>("description_root");
                     video.Thumb = getImageUrl(item);
                     video.Airdate = item.Value<string>("publication_start_dt") + ' ' + item.Value<string>("publication_start_hour");
                     result.Add(video);
                 }
             return result;
         }
     }
     return null;
 }
        public IHttpActionResult Create(CategoryBindingModel categoryBindingModel)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            bool duplicatedCategory = this.data
                .Categories
                .All()
                .FirstOrDefault(c => c.Name == categoryBindingModel.Name) != null;

            if (duplicatedCategory)
            {
                return this.BadRequest("A category with the same name already exists");
            }

            Category category = new Category
            {
                Name = categoryBindingModel.Name
            };

            this.data.Categories.Add(category);
            this.data.Save();

            CategoryViewModel categoryViewModel = CategoryViewModel.ConvertToCategoryViewModel(category);

            return this.Ok(categoryViewModel);
        }
 public override void SaveCategoryToJournal(Category cat)
 {
     EnsureJournalItem(cat);
 }
 public async Task <Category> UpsertCategoryAsync(Category category)
 {
     return(await _upsertCategoryCommand.UpsertCategoryAsync(category));
 }
Esempio n. 33
0
        private void CollectParameterValues(Element element)
        {
            try
            {
                if (null != element.Category)
                {
                    Category category = element.Category;
                    Dictionary <int, ParameterProperties> paramDictionary = new Dictionary <int, ParameterProperties>();
                    if (parameterMaps.ContainsKey(category.Id.IntegerValue))
                    {
                        paramDictionary = parameterMaps[category.Id.IntegerValue];
                        foreach (Parameter param in element.Parameters)
                        {
                            if (param.StorageType == StorageType.ElementId)
                            {
                                if (param.Id.IntegerValue != (int)BuiltInParameter.PHASE_CREATED && param.Id.IntegerValue != (int)BuiltInParameter.PHASE_DEMOLISHED)
                                {
                                    continue;
                                }
                            }

                            if (paramDictionary.ContainsKey(param.Id.IntegerValue))
                            {
                                //paramDictionary[param.Id.IntegerValue].AddValue(param);
                                paramDictionary.Remove(param.Id.IntegerValue);
                            }
                            ParameterProperties pp = new ParameterProperties(param);
                            pp.AddValue(param);
                            paramDictionary.Add(pp.ParamId, pp);
                        }
                        parameterMaps.Remove(category.Id.IntegerValue);
                    }
                    else
                    {
                        foreach (Parameter param in element.Parameters)
                        {
                            if (param.StorageType == StorageType.ElementId)
                            {
                                if (param.Id.IntegerValue != (int)BuiltInParameter.PHASE_CREATED && param.Id.IntegerValue != (int)BuiltInParameter.PHASE_DEMOLISHED)
                                {
                                    continue;
                                }
                            }

                            if (param.Definition.Name.Contains("Extensions."))
                            {
                                continue;
                            }
                            if (!paramDictionary.ContainsKey(param.Id.IntegerValue))
                            {
                                ParameterProperties pp = new ParameterProperties(param);
                                pp.AddValue(param);
                                paramDictionary.Add(pp.ParamId, pp);
                            }
                        }
                    }
                    parameterMaps.Add(category.Id.IntegerValue, paramDictionary);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect parameter information.\n" + ex.Message, "Collect Parameter Values", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 34
0
 public ClearWantedLevel(string name, MenuType menuType, Category category) : base(name, menuType, category)
 {
 }
 public override IEnumerable <string> GetTaxonomyTerms(Category category)
 {
     return(GetTaxonomyTerms(category.Bvin));
 }
        public override void UpdateCategoryTaxonomy(Category cat, IEnumerable <string> taxonomyTags)
        {
            var journalItem = EnsureJournalItem(cat);

            UpdateTaxonomy(journalItem, taxonomyTags);
        }
 public override ISocialItem GetCategorySocialItem(Category cat)
 {
     SaveCategoryToJournal(cat);
     return(new StubSocialItem());
 }
 public void Insert(Category p)
 {
     _object.Add(p);
     c.SaveChanges();
 }
Esempio n. 39
0
 void FilterData(Category category)
 {
     filteredVerses = new ObservableSortedList <Verse> (from verse in verses
                                                        where verse.Category == category
                                                        select verse);
 }
 public void Update(Category p)
 {
     c.SaveChanges();
 }
Esempio n. 41
0
        private void AddCategories()
        {
            var categories = Category.GetCategories();

            foreach (var category in categories)
            {
                var questions = Question.GetQuestions(category.CategoryId);

                RadPageViewPage newPage = new RadPageViewPage
                {
                    Name  = category.CategoryName + "_cat",
                    Text  = category.CategoryName,
                    Title = category.CategoryName
                };

                RadWizard radWizard = new RadWizard
                {
                    Name         = $"wizard_{category.CategoryName}",
                    Text         = category.CategoryName,
                    ThemeName    = "Crystal",
                    Dock         = DockStyle.Fill,
                    CancelButton = { Visibility = ElementVisibility.Hidden },
                    FinishButton = { Visibility = ElementVisibility.Visible },
                    BackButton   = { Visibility = ElementVisibility.Hidden },
                    HelpButton   = { Visibility = ElementVisibility.Hidden },
                };

                radWizard.Finish += RadWizardOnFinish;
                radWizard.Next   += RadWizardOnNext;

                foreach (var question in questions)
                {
                    var answers = Answer.GetAnswers(question.QuestionId);

                    WizardPage wizardPage = new WizardPage
                    {
                        Tag       = question,
                        Text      = category.CategoryName,
                        Title     = category.CategoryName,
                        AutoSize  = true,
                        BackColor = Color.Transparent
                    };

                    RadGroupBox radGroupBox = new RadGroupBox()
                    {
                        HeaderText = "Answers",
                        Name       = $"answers_{category.CategoryId}",
                        Location   = new Point(25, 80),
                        Size       = new Size(600, 250),
                        ThemeName  = "MaterialTeal",
                    };

                    RadLabel questionLabel = new RadLabel
                    {
                        ThemeName = "MaterialTeal",
                        Name      = $"q_{question.QuestionId}Label",
                        Text      = $"{question.question}",
                        AutoSize  = true,
                        Location  = new Point(25, 25),
                        Font      = new Font(FontFamily.GenericSerif, 15)
                    };

                    int i = 1;
                    foreach (Answer answer in answers)
                    {
                        radGroupBox.Controls.Add(new RadRadioButton()
                        {
                            Name      = "answer_" + answer.AnswerId,
                            Text      = answer.answer,
                            Tag       = answer,
                            Location  = new Point(30, 85 + (25 * i)),
                            ThemeName = "MaterialTeal"
                        });
                        i++;
                    }

                    wizardPage.ContentArea = new Panel();
                    radWizard.Pages.Add(wizardPage);

                    RadButton detailsButton = new RadButton {
                        Text      = "Details",
                        Location  = new Point(450, 250),
                        ThemeName = "MaterialTeal"
                    };
                    detailsButton.Click += delegate(object sender, EventArgs args)
                    {
                        var catInfo     = CategoryInfo.GetCategoryInfo(category.CategoryId);
                        var detailsForm = new CategoryInformationForm(catInfo, category.CategoryName);
                        detailsForm.Show();
                    };

                    wizardPage.ContentArea.Controls.Add(detailsButton);
                    wizardPage.ContentArea.Controls.Add(questionLabel);
                    wizardPage.ContentArea.Controls.Add(radGroupBox);
                }

                //radWizard.Pages.Add(radWizard.CompletionPage);

                newPage.Controls.Add(radWizard);
                tabViews.Pages.Add(newPage);
            }
        }
 public void Delete(Category p)
 {
     _object.Remove(p);
     c.SaveChanges();
 }
Esempio n. 43
0
 public ObjectSelection Exclusive(Category singleCat)
 {
     return(this.Clear(Category.All & ~singleCat));
 }
Esempio n. 44
0
        //public CollisionInfo collisions;

        public ZombieController(Body body, Category collisionMask) : base(body, collisionMask)
        {
            collisions.faceDirection = 1;
        }
Esempio n. 45
0
 protected void LocalExclusive(Category singleCat)
 {
     this.LocalClear(Category.All & ~singleCat);
 }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp      = commandData.Application;
            Application   app        = uiapp.Application;
            Document      doc        = uiapp.ActiveUIDocument.Document;
            Categories    categories = doc.Settings.Categories;

            int nCategories = categories.Size;

            Debug.Print(
                "{0} categories and their parents obtained "
                + "from the Categories collection:",
                nCategories);

            foreach (Category c in categories)
            {
                Category p = c.Parent;

                Debug.Print("  {0} ({1}), parent {2}",
                            c.Name, c.Id.IntegerValue,
                            (null == p ? "<none>" : p.Name));
            }

            Array bics = Enum.GetValues(
                typeof(BuiltInCategory));

            int nBics = bics.Length;

            Debug.Print("{0} built-in categories and the "
                        + "corresponding document ones:", nBics);

            Category cat;
            string   s;

            List <BuiltInCategory> bics_null
                = new List <BuiltInCategory>();

            List <BuiltInCategory> bics_exception
                = new List <BuiltInCategory>();

            foreach (BuiltInCategory bic in bics)
            {
                try
                {
                    cat = categories.get_Item(bic);

                    if (null == cat)
                    {
                        bics_null.Add(bic);
                        s = "<null>";
                    }
                    else
                    {
                        s = string.Format("{0} ({1})",
                                          cat.Name, cat.Id.IntegerValue);
                    }
                }
                catch (Exception ex)
                {
                    bics_exception.Add(bic);

                    s = ex.GetType().Name + " " + ex.Message;
                }
                Debug.Print("  {0} --> {1}",
                            bic.ToString(), s);
            }

            int nBicsNull      = bics_null.Count;
            int nBicsException = bics_exception.Count;

#if ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR
            // Trying to use OfClass( typeof( Category ) )
            // throws an ArgumentException exception saying
            // "Input type Category is not a recognized
            // Revit API type".

            IEnumerable <Category> cats
                = new FilteredElementCollector(doc)
                  .WhereElementIsNotElementType()
                  .WhereElementIsViewIndependent()
                  .Cast <Category>();

            // Unable to cast object of type
            // 'Autodesk.Revit.DB.Element' to type
            // 'Autodesk.Revit.DB.Category':

            int nCategoriesFiltered = cats.Count <Category>();

            Debug.Print(
                "{0} categories obtained from a filtered "
                + "element collector:",
                nCategoriesFiltered);

            foreach (Category c in cats)
            {
                Debug.Print("  {0}", c.Name);
            }
#endif // ACCESS_HIDDEN_CATEGORIES_THROUGH_FILTERED_ELEMENT_COLLECTOR

            TaskDialog dlg = new TaskDialog(
                "Hidden Built-in Categories");

            s = string.Format(
                "{0} categories obtained from the Categories collection;\r\n"
                + "{1} built-in categories;\r\n"
                + "{2} built-in categories retrieve null result;\r\n"
                + "{3} built-in categories throw an exception:\r\n",
                nCategories, nBics, nBicsNull, nBicsException);

            Debug.Print(s);

            dlg.MainInstruction = s;

            s = bics_exception
                .Aggregate <BuiltInCategory, string>(
                string.Empty,
                (a, bic) => a + "\n" + bic.ToString());

            Debug.Print(s);

            dlg.MainContent = s;

            dlg.Show();

            return(Result.Succeeded);
        }
        public async Task <ActionResult> Create([FromForm] Category data)
        {
            var resp = await svc.newCategory(data);

            return(Ok(resp));
        }
Esempio n. 48
0
 protected void LocalClear(Category clearCat)
 {
     this.obj.RemoveAll(o => (GetObjCategory(o) & clearCat) != Category.None);
     this.UpdateCategories();
 }
Esempio n. 49
0
 public static int AddCategory(Category data)
 {
     return CategoryDB.Add(data);
 }
Esempio n. 50
0
 public ObjectSelection(ObjectSelection other)
 {
     this.obj = new List <object>(other.obj);
     this.cat = other.cat;
 }
 public CategoryDetailPage(Category category)
 {
     InitializeComponent();
     BindingContext = new CategoryDetailViewModel(category);
 }
Esempio n. 52
0
 /// <summary>
 /// Cập nhật loại hàng
 /// </summary>
 /// <param name="categoryID"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static bool UpdateCategory(int categoryID, Category data)
 {
     return CategoryDB.Update(categoryID, data);
 }
Esempio n. 53
0
        public MaterialsAMLPaletteRequest(UIApplication uiApp, String text)
        {
            RVTDocument         doc = uiApp.ActiveUIDocument.Document;
            MaterialsAMLPalette materialsPalette = BARevitTools.Application.thisApp.newMainUi.materialsAMLPalette;

            //Get the versioned symbol family
            FamilySymbol familySymbol    = null;
            string       versionedFamily = RVTOperations.GetVersionedFamilyFilePath(uiApp, Properties.Settings.Default.RevitIDAccentMatTag);

            //Try loading the family symbol
            Transaction loadSymbolTransaction = new Transaction(doc, "LoadFamilySymbol");

            loadSymbolTransaction.Start();
            try
            {
                try
                {
                    IFamilyLoadOptions loadOptions = new RVTFamilyLoadOptions();
                    doc.LoadFamilySymbol(versionedFamily, "Legend Tag (Fake)", loadOptions, out FamilySymbol symb);
                    familySymbol = symb;
                }
                catch
                {
                    MessageBox.Show(String.Format("Could not get the 'Legend Tag (Fake)' type from {0}", versionedFamily), "Family Symbol Load Error");
                }
                loadSymbolTransaction.Commit();
            }
            catch (Exception transactionException)
            { loadSymbolTransaction.RollBack(); MessageBox.Show(transactionException.ToString()); }

            //Get the line style to use, or create the default
            Element lineStyle = null;

            if (materialsPalette.paletteMaterialComboBox.Text == "Default")
            {
                try
                {
                    lineStyle = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines).SubCategories.get_Item("6 BA ID ACCENT").GetGraphicsStyle(GraphicsStyleType.Projection);
                }
                catch
                {
                    try
                    {
                        Category linesCategory        = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines);
                        Category newLineStyleCategory = doc.Settings.Categories.NewSubcategory(linesCategory, "6 BA ID ACCENT");
                        newLineStyleCategory.LineColor = new Color(0, 0, 0);
                        newLineStyleCategory.SetLineWeight(6, GraphicsStyleType.Projection);
                        newLineStyleCategory.SetLinePatternId(LinePatternElement.GetSolidPatternId(), GraphicsStyleType.Projection);
                        doc.Regenerate();
                        lineStyle = newLineStyleCategory.GetGraphicsStyle(GraphicsStyleType.Projection);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                    }
                }
            }
            else
            {
                lineStyle = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines).SubCategories.get_Item("ID " + materialsPalette.paletteMaterialComboBox.Text).GetGraphicsStyle(GraphicsStyleType.Projection);
            }

            //Assure the view being used is a floor plan
            if (doc.ActiveView.ViewType != ViewType.FloorPlan)
            {
                MessageBox.Show("This tool should be used ina a Floor Plan or Area Plan view");
            }
            else
            {
                //Create a loop for picking points. Change the palette background color based on the number of points picked
                List <XYZ> pickedPoints = new List <XYZ>();
                bool       breakLoop    = false;
                int        pickCount    = 0;
                while (breakLoop == false)
                {
                    try
                    {
                        //Have the user begin picking points. The number of clicks to start the UI color change is 1 because the first click is usually to activate the window.
                        XYZ point = uiApp.ActiveUIDocument.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.Endpoints, "Click points for the line to follow. Then click once to the side where the lines should be drawn. Hit ESC to finish");
                        pickedPoints.Add(point);

                        if (pickCount == 1)
                        {
                            materialsPalette.BackColor = System.Drawing.Color.Firebrick;
                        }
                        else if (pickCount == 2)
                        {
                            materialsPalette.BackColor = System.Drawing.Color.Orange;
                        }
                        else if (pickCount > 2)
                        {
                            //After three clicks in the window, the user has made the minimum point selection to generate the lines from the start, end, and positive side points.
                            materialsPalette.BackColor = System.Drawing.Color.GreenYellow;
                        }
                        else
                        {
                            ;
                        }

                        pickCount++;
                    }
                    catch
                    {
                        materialsPalette.BackColor = MaterialsAMLPalette.DefaultBackColor;
                        breakLoop = true;
                    }
                }

                //Get rid of the first point from clicking into the Revit view. This point is not needed.
                pickedPoints.RemoveAt(0);

                if (pickedPoints.Count > 2)
                {
                    Transaction createLinesTransaction = new Transaction(doc, "CreateAccentLines");
                    createLinesTransaction.Start();

                    try
                    {
                        //These points will be used in determining the start, end, and room points
                        XYZ firstPoint = pickedPoints[0];
                        XYZ roomPoint  = pickedPoints[pickedPoints.Count - 1];
                        XYZ lastPoint  = pickedPoints[pickedPoints.Count - 2];

                        //Create  a list of points for the polyline that excludes the room point
                        List <XYZ> polyLinePoints = new List <XYZ>();
                        for (int i = 0; i < pickedPoints.Count - 1; i++)
                        {
                            polyLinePoints.Add(pickedPoints[i]);
                        }

                        //Create a polyline from the list of picked points and then get make lines from the points on the poly line
                        PolyLine    guidePolyLine = PolyLine.Create(polyLinePoints);
                        IList <XYZ> polyPoints    = guidePolyLine.GetCoordinates();

                        List <Line> guideLines = new List <Line>();
                        for (int i = 0; i < polyLinePoints.Count - 1; i++)
                        {
                            guideLines.Add(Line.CreateBound(polyLinePoints[i], polyLinePoints[i + 1]));
                        }

                        //Get the direction of the line offset by measuring the first offset for positive and negative values and comparing their distances with the room point
                        bool positiveZ = false;

                        List <Line> offsetLines            = new List <Line>();
                        Line        positiveOffsetLine     = guideLines.Last().CreateOffset(0.6666666667d, XYZ.BasisZ) as Line;
                        Line        negativeOffsetLine     = guideLines.Last().CreateOffset(-0.6666666667d, XYZ.BasisZ) as Line;
                        XYZ         positiveOffsetMidPoint = positiveOffsetLine.Evaluate(0.5d, true);
                        XYZ         negativeOffsetMidPoint = negativeOffsetLine.Evaluate(0.5d, true);

                        Double positiveOffsetDistance = positiveOffsetMidPoint.DistanceTo(roomPoint);
                        Double negativeOffsetDistance = negativeOffsetMidPoint.DistanceTo(roomPoint);

                        //If the positive offset side resulted in a shorter distance to the point inside the room, then the offset should have a positive Z normal.
                        if (positiveOffsetDistance < negativeOffsetDistance)
                        {
                            positiveZ = true;
                        }

                        //Knowing whether or not to use a positive or negative offset, begin creating offset lines for each guide line
                        foreach (Line guideLine in guideLines)
                        {
                            if (positiveZ)
                            {
                                offsetLines.Add(guideLine.CreateOffset(0.6666666667d, XYZ.BasisZ) as Line);
                            }
                            else
                            {
                                offsetLines.Add(guideLine.CreateOffset(-0.6666666667d, XYZ.BasisZ) as Line);
                            }
                        }

                        //Determine if the number of line segments is 1 or more
                        Line firstLine = offsetLines.First();
                        Line lastLine  = null;
                        if (offsetLines.Count > 1)
                        {
                            lastLine = offsetLines.Last();
                        }

                        //If there is only one line segment, both end operations must be performed on it
                        if (lastLine == null)
                        {
                            double lineLength       = firstLine.Length;
                            double fractionOfLength = 0.6666666667d / lineLength;

                            //Checking fractions to ensure they are not greater than 1 for the normalization
                            if (fractionOfLength > 1)
                            {
                                fractionOfLength = 0.25d;
                            }

                            //Re-evaluating where to place the start and end point of the line
                            XYZ shiftedStartPoint = firstLine.Evaluate(fractionOfLength, true);
                            XYZ shiftedEndPoint   = firstLine.Evaluate(1 - fractionOfLength, true);
                            firstLine = Line.CreateBound(shiftedStartPoint, shiftedEndPoint);

                            //Creating the angled corner lines
                            Line firstCornerLine = Line.CreateBound(firstPoint, firstLine.GetEndPoint(0));
                            Line lastCornerLine  = Line.CreateBound(lastPoint, firstLine.GetEndPoint(1));

                            //Create the detail lines from the lines
                            DetailCurve newAccentLine1 = doc.Create.NewDetailCurve(doc.ActiveView, firstCornerLine);
                            DetailCurve newAccentLine2 = doc.Create.NewDetailCurve(doc.ActiveView, firstLine);
                            DetailCurve newAccentLine3 = doc.Create.NewDetailCurve(doc.ActiveView, lastCornerLine);

                            //Assign a line style to the newly created detail lines
                            newAccentLine1.LineStyle = lineStyle;
                            newAccentLine2.LineStyle = lineStyle;
                            newAccentLine3.LineStyle = lineStyle;


                            XYZ    tagPlacementPoint = firstLine.Evaluate(0.5d, true);
                            XYZ    direction         = firstLine.Direction;
                            Line   axisLine          = Line.CreateUnbound(tagPlacementPoint, XYZ.BasisZ);
                            double rotationAngle     = direction.AngleTo(XYZ.BasisX);

                            //Get the midpoint of the line, its direction, and create the rotation and axis
                            if (familySymbol != null)
                            {
                                //Create the tag instance
                                FamilyInstance newTag = doc.Create.NewFamilyInstance(tagPlacementPoint, familySymbol, doc.ActiveView);
                                //Rotate the new tag instance
                                ElementTransformUtils.RotateElement(doc, newTag.Id, axisLine, rotationAngle);
                            }

                            createLinesTransaction.Commit();
                        }
                        //If there is more than one line segment, an operation must be performed on the start and end of the start and end lines, respectively
                        else
                        {
                            List <Line> linesToDraw = new List <Line>();
                            // Get the normalized value for 8" relative to the lengths of the start and end lines
                            double firstLineLength     = firstLine.Length;
                            double fractionOfFirstLine = 0.6666666667 / firstLineLength;
                            double lastLineLength      = lastLine.Length;
                            double fractionOfLastLine  = 0.666666667 / lastLineLength;

                            //Checking fractions to ensure they are not greater than 1 for the normalization
                            if (fractionOfFirstLine > 1)
                            {
                                fractionOfFirstLine = 0.25d;
                            }
                            if (fractionOfLastLine > 1)
                            {
                                fractionOfLastLine = 0.25d;
                            }

                            //Shift the ends of the start and end lines by finding the point along the line relative to the normalized 8" value
                            XYZ shiftedStartPoint = firstLine.Evaluate(fractionOfFirstLine, true);
                            XYZ shiftedEndPoint   = lastLine.Evaluate(1 - fractionOfLastLine, true);

                            //Reset the start and end lines with the new shifted points
                            firstLine = Line.CreateBound(shiftedStartPoint, firstLine.GetEndPoint(1));
                            lastLine  = Line.CreateBound(lastLine.GetEndPoint(0), shiftedEndPoint);
                            linesToDraw.Add(firstLine);

                            //If there are only 3 offset lines, there will be just one middle segment
                            if (offsetLines.Count == 3)
                            {
                                linesToDraw.Add(offsetLines[1]);
                            }
                            //If there are more than three offset lines, there will be more than one middle line segment
                            else
                            {
                                List <Line> middleLines = offsetLines.GetRange(1, offsetLines.Count - 2);
                                foreach (Line middleLine in middleLines)
                                {
                                    linesToDraw.Add(middleLine);
                                }
                            }
                            linesToDraw.Add(lastLine);

                            //For the lines to draw, intersect them with the next line in the list and reset their start and end points to be the intersection
                            for (int i = 0; i < linesToDraw.Count - 1; i++)
                            {
                                Line line1       = linesToDraw[i];
                                Line scaledLine1 = Line.CreateUnbound(line1.GetEndPoint(1), line1.Direction);
                                Line line2       = linesToDraw[i + 1];
                                Line scaledLine2 = Line.CreateUnbound(line2.GetEndPoint(0), line2.Direction.Negate());
                                SetComparisonResult intersectionResult = scaledLine1.Intersect(scaledLine2, out IntersectionResultArray results);
                                if (intersectionResult == SetComparisonResult.Overlap)
                                {
                                    IntersectionResult result = results.get_Item(0);
                                    Line newLine1             = Line.CreateBound(line1.GetEndPoint(0), result.XYZPoint);
                                    Line newLine2             = Line.CreateBound(result.XYZPoint, line2.GetEndPoint(1));

                                    linesToDraw[i]     = newLine1;
                                    linesToDraw[i + 1] = newLine2;
                                }
                            }

                            //Create the angled corner lines at the start and end of the line chain
                            Line firstCornerLine = Line.CreateBound(firstPoint, firstLine.GetEndPoint(0));
                            Line lastCornerLine  = Line.CreateBound(lastPoint, lastLine.GetEndPoint(1));
                            linesToDraw.Add(firstCornerLine);
                            linesToDraw.Add(lastCornerLine);

                            //Create each line as a detail line
                            foreach (Line apiLine in linesToDraw)
                            {
                                DetailCurve newAccentLine = doc.Create.NewDetailCurve(doc.ActiveView, apiLine);
                                newAccentLine.LineStyle = lineStyle;
                            }

                            //Declare some stuff for use in the symbol placement
                            Line   firstMiddleLine = linesToDraw[0];
                            Line   lastMiddleLine  = linesToDraw[linesToDraw.Count - 3];
                            XYZ    firstTagPoint   = firstMiddleLine.Evaluate(0.5d, true);
                            XYZ    lastTagPoint    = lastMiddleLine.Evaluate(0.5d, true);
                            XYZ    firstDirection  = firstMiddleLine.Direction;
                            XYZ    lastDirection   = lastMiddleLine.Direction;
                            Line   firstAxisLine   = Line.CreateUnbound(firstTagPoint, XYZ.BasisZ);
                            Line   lastAxisLine    = Line.CreateUnbound(lastTagPoint, XYZ.BasisZ);
                            double firstRotation   = firstDirection.AngleTo(XYZ.BasisX);
                            double lastRotation    = lastDirection.AngleTo(XYZ.BasisX);

                            if (familySymbol != null)
                            {
                                //Create tag at the beginning of the middle lines
                                FamilyInstance firstTag = doc.Create.NewFamilyInstance(firstTagPoint, familySymbol, doc.ActiveView);
                                ElementTransformUtils.RotateElement(doc, firstTag.Id, firstAxisLine, firstRotation);

                                //Create a tag at the end of the middle lines if there are more than 2 middle lines
                                if (linesToDraw.Count > 4)
                                {
                                    FamilyInstance lastTag = doc.Create.NewFamilyInstance(lastTagPoint, familySymbol, doc.ActiveView);
                                    ElementTransformUtils.RotateElement(doc, lastTag.Id, lastAxisLine, lastRotation);
                                }
                            }

                            createLinesTransaction.Commit();
                        }
                    }
                    catch (Exception e)
                    {
                        //Suppose the user closed the palette too soon. This will remind them to keep it open.
                        if (BARevitTools.Application.thisApp.newMainUi.materialsAMLPalette == null)
                        {
                            MessageBox.Show("AML Picker was closed prematurely. Please keep the picker open until the lines are drawn.");
                        }
                        else
                        {
                            //Otherwise, if some other error occurred, show the exception
                            MessageBox.Show(e.ToString());
                        }
                        createLinesTransaction.RollBack();
                    }
                }
                else
                {
                    ;
                }
            }
        }
Esempio n. 54
0
        public IActionResult Index()
        {
            var basketProductCookie = Request.Cookies["InCard"];
            ViewBag.Cookie = basketProductCookie;

            Dictionary<Category, IEnumerable<Product>> categoryByProducts = new Dictionary<Category, IEnumerable<Product>>();

            foreach (var category in _reminddb.Categories)
            {
                var categorymarkas = _reminddb.CategoryMarkas.Include(x => x.Category)
                    .Include(x => x.Products)
                    .Include("Products.Images")
                    .Where(x => x.CategoryId == category.Id);
                var products = new List<Product>();
                var categoryy = new Category();
                foreach (var item in categorymarkas)
                {
                    products.AddRange(item.Products);
                    categoryy = item.Category;
                }
                categoryByProducts.Add(categoryy, products);
            }

            //List<Product> ProductToCategory = _reminddb.Products.Include(x => x.CategoryMarka).Include(y => y.CategoryMarka.Marka).Include(i => i.CategoryMarka.Category)
            //  .Include(m => m.Images).Where(pr => (CategoryId == null || pr.CategoryMarka.CategoryId == categoryid) &&
            //  (productid == null || pr.Id == productid)).OrderByDescending(m => m.Id).Take(_take).ToList();


            RemindViewModel remindproduct = new RemindViewModel()
            {
                CategoryByProducts = categoryByProducts,
                CategoryMarkas = _reminddb.CategoryMarkas.Include(p => p.Products).
                 Include(m => m.Category).Where(x => x.CategoryId == x.Category.Id),
                Categories = _reminddb.Categories
                .Include(x => x.CategoryMarkas)
                .Include("CategoryMarkas.Products")
                .Include("CategoryMarkas.Products.Images"),
                Markas = _reminddb.Markas.Include(y => y.CategoryMarkas),

                Products = _reminddb.Products
                .Include(i => i.Images)
                .Include(l => l.Likes)
                .Include(j => j.CategoryMarka)
                .Include(c => c.CategoryMarka.Category)
                .Include(d => d.CategoryMarka.Marka)
                .Include(od => od.OrderDetails),
                Images = _reminddb.Images.Include(i => i.Product),
                Likes = _reminddb.Likes,

                Orders = _reminddb.Orders.Include(odet => odet.OrderDetails),
                OrderDetails = _reminddb.OrderDetails,

                NewUsers = _reminddb.Users.Include(like => like.Likes).Include(order => order.Orders),
                HomeSliderBigs = _reminddb.HomeSliderBigs
               
            };

            return View(remindproduct);


        }
Esempio n. 55
0
        public Category Put([FromBody] Category category)
        {
            _repository.Update(category);

            return(category);
        }
Esempio n. 56
0
 public CategoryProduct(Category category, Product product)
 {
     Category = category;
     Product  = product;
 }
Esempio n. 57
0
        protected override void Seed(ApplicationDbContext context)
        {
            var userManager = new ApplicationUserManager(new UserStore <User>(context));
            var roleManager = new ApplicationRoleManager(new RoleStore <IdentityRole>(context));

            #region Users

            var roles = new List <IdentityRole>
            {
                new IdentityRole
                {
                    Name = UserRole.SuperAdmin
                },
                new IdentityRole
                {
                    Name = UserRole.Administrator
                },
                new IdentityRole
                {
                    Name = UserRole.Buyer
                },
                new IdentityRole
                {
                    Name = UserRole.Seller
                },
                new IdentityRole
                {
                    Name = UserRole.Banned
                }
            };

            foreach (var identityRole in roles)
            {
                var existingRole = roleManager.FindByName(identityRole.Name);
                if (existingRole == null)
                {
                    roleManager.Create(identityRole);
                }
            }

            var superAdmin = new User //only one, always
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                Id             = Guid.NewGuid().ToString()
            };
            var superAdminPassword = "******";

            var adminUsers = new List <User>
            {
                new User
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Id             = Guid.NewGuid().ToString()
                }
            };

            var buyerUsers = new List <User>
            {
                new User
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Id             = Guid.NewGuid().ToString()
                }
            };

            var sellerUsers = new List <User>
            {
                new User
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    Id             = Guid.NewGuid().ToString()
                }
            };

            var eUser = userManager.FindByName(superAdmin.UserName);
            if (eUser == null)
            {
                userManager.Create(superAdmin, superAdminPassword);
                userManager.SetLockoutEnabled(superAdmin.Id, false);

                var rolesForUser = userManager.GetRoles(superAdmin.Id);
                if (!rolesForUser.Contains(UserRole.SuperAdmin))
                {
                    userManager.AddToRole(superAdmin.Id, UserRole.SuperAdmin);
                }
            }

            foreach (var applicationUser in adminUsers)
            {
                var existingUser = userManager.FindByName(applicationUser.UserName);
                if (existingUser == null)
                {
                    userManager.Create(applicationUser, Common.Constants.Password);
                    userManager.SetLockoutEnabled(applicationUser.Id, false);

                    var rolesForUser = userManager.GetRoles(applicationUser.Id);
                    if (!rolesForUser.Contains(UserRole.Administrator))
                    {
                        userManager.AddToRole(applicationUser.Id, UserRole.Administrator);
                    }
                }
            }

            foreach (var applicationUser in buyerUsers)
            {
                var existingUser = userManager.FindByName(applicationUser.UserName);
                if (existingUser == null)
                {
                    userManager.Create(applicationUser, Common.Constants.Password);
                    userManager.SetLockoutEnabled(applicationUser.Id, false);

                    var rolesForUser = userManager.GetRoles(applicationUser.Id);
                    if (!rolesForUser.Contains(UserRole.Buyer))
                    {
                        userManager.AddToRole(applicationUser.Id, UserRole.Buyer);
                    }

                    context.Buyers.Add(new Buyer
                    {
                        Id = applicationUser.Id
                    });
                }
            }

            foreach (var applicationUser in sellerUsers)
            {
                var existingUser = userManager.FindByName(applicationUser.UserName);
                if (existingUser == null)
                {
                    userManager.Create(applicationUser, Common.Constants.Password);
                    userManager.SetLockoutEnabled(applicationUser.Id, false);

                    var rolesForUser = userManager.GetRoles(applicationUser.Id);
                    if (!rolesForUser.Contains(UserRole.Seller))
                    {
                        userManager.AddToRole(applicationUser.Id, UserRole.Seller);
                    }

                    context.Sellers.Add(new Seller
                    {
                        Id            = applicationUser.Id,
                        Alias         = applicationUser.UserName + "Alias",
                        ContactPhone  = "0987654321",
                        OfficeAddress = "Kiev, Sechenova, 6"
                    });
                }
            }

            #endregion

            var category = new Category
            {
                Name = "Electronics",
                Id   = "307b21c4-1d3a-4884-8c88-25082d785a8f"
            };
            var categories = new List <Category>
            {
                new Category
                {
                    Name = "Clothes",
                    Id   = "E8C33859-C8FA-4BB3-A5C1-0E769FF3A475"
                },
                new Category
                {
                    MasterCategoryId = "307b21c4-1d3a-4884-8c88-25082d785a8f",
                    Name             = "Computers",
                    Id = "C764CE78-314E-4B78-B984-04C9751F678D"
                },
                new Category
                {
                    Name = "Sport",
                    Id   = "a515a13e-6d78-416e-826b-10bf01ae9b1b"
                },
                new Category
                {
                    Name = "House and garden",
                    Id   = "d345D13a-6d78-416e-826b-10bf01ae9b1b"
                },
            };

            var categ = context.Categories.FirstOrDefault(item => item.Name == category.Name);
            if (categ == null)
            {
                context.Categories.Add(category);
            }

            foreach (var categor in categories)
            {
                var existingCategory = context.Categories.FirstOrDefault(item => item.Name == categor.Name);
                if (existingCategory == null)
                {
                    context.Categories.Add(categor);
                }
            }

            var products = new List <Product>
            {
                new Product
                {
                    CategoryId  = "C764CE78-314E-4B78-B984-04C9751F678D",
                    Name        = "Lenovo G510",
                    Description = "Very Good notepad",
                    Amount      = 1,
                    Price       = 5000M,
                    SellerId    = userManager.FindByName("seller").Id
                },
                new Product
                {
                    CategoryId  = "E8C33859-C8FA-4BB3-A5C1-0E769FF3A475",
                    Name        = "Wool hat",
                    Description = "Very warm",
                    Amount      = 2,
                    Price       = 100M,
                    SellerId    = userManager.FindByName("seller").Id
                },
                new Product
                {
                    CategoryId  = "a515a13e-6d78-416e-826b-10bf01ae9b1b",
                    Name        = "Weights",
                    Description = "Very heavy",
                    Amount      = 2,
                    Price       = 500M,
                    SellerId    = userManager.FindByName("seller").Id
                },
                new Product
                {
                    CategoryId  = "d345D13a-6d78-416e-826b-10bf01ae9b1b",
                    Name        = "Shovel \"Tyapka\"",
                    Description = "Good",
                    Amount      = 1,
                    Price       = 300M,
                    SellerId    = userManager.FindByName("seller").Id
                }
            };

            foreach (var product in products)
            {
                var existingProduct = context.Products.FirstOrDefault(item => item.Name == product.Name);
                if (existingProduct == null)
                {
                    context.Products.Add(product);
                }
            }

            base.Seed(context);
        }
Esempio n. 58
0
        public Category Delete([FromBody] Category category)
        {
            _repository.Excluir(category);

            return(category);
        }
        public static void Initialize(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();

            if (!context.Categories.Any())
            {
                var categories = new Category[]
                {
                    new Category {
                        Name = "Beverages", Description = "coffee/tea, juice, soda"
                    },
                    new Category {
                        Name = "Bread/Bakery", Description = "sandwich loaves, dinner rolls, tortillas, bagels"
                    },
                    new Category {
                        Name = "Dairy", Description = "cheeses, eggs, milk, yogurt, butter"
                    },
                    new Category {
                        Name = "Dry/Baking Goods", Description = "cereals, flour, sugar, pasta, mixes"
                    },
                    new Category {
                        Name = "Frozen Foods", Description = "waffles, vegetables, individual meals, ice cream"
                    },
                    new Category {
                        Name = "Meat", Description = "lunch meat, poultry, beef, pork"
                    },
                    new Category {
                        Name = "Produce", Description = "fruits, vegetables"
                    },
                    new Category {
                        Name = "Cleaners", Description = "laundry detergent, dishwashing liquid/detergent"
                    },
                    new Category {
                        Name = "Paper Goods", Description = "paper towels, toilet paper, aluminum foil, sandwich bags"
                    },
                    new Category {
                        Name = "Personal Care", Description = "shampoo, soap, hand soap, shaving cream"
                    },
                    new Category {
                        Name = "Other", Description = "baby items, pet items, batteries, greeting cards"
                    },
                };

                foreach (Category c in categories)
                {
                    context.Categories.Add(c);
                }
                context.SaveChanges();
            }



            if (!context.Products.Any())
            {
                var products = new Product[]
                {
                    new Product {
                        Name = "Nescafe Gold Coffee-50gm", Description = "Nescafe Gold is a blend of mountain grown Arabica and Robusta beans.", Price = 450.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Himalayan Java Coffee - Thamel Roast, 250 gms", Description = "Himalayan Java Coffee", Price = 825.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Himalayan Java Coffee - Medium Roast, 450 gms", Description = "Himalayan Java Coffee", Price = 1400.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Nescafe Gold Coffee - 100gm", Description = "Premium, imported, freeze dried soluble coffee powder.", Price = 780.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Somersby Apple Cider Bottle 250ML", Description = "Somersby is Carlsberg Group's biggest selling cider", Price = 165.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Rakura Supreme CTC Tea, 500gm", Description = "Rakura Tea", Price = 295.00m, CategoryId = 1
                    },
                    new Product {
                        Name = "Tokla Tea Bags - 100 Packets", Description = "Tokla Tea", Price = 165.00m, CategoryId = 1
                    },

                    new Product {
                        Name = "Trisara Bakery Soup Stick Bread, 15 piece", Description = "Bread sticks are commonly served with soups", Price = 75.00m, CategoryId = 2
                    },
                    new Product {
                        Name = "European Bakery Brown Bread", Description = "", Price = 140.00m, CategoryId = 2
                    },
                    new Product {
                        Name = "Nanglo Brown Bread - 500 gm", Description = "Brown Bread", Price = 88.00m, CategoryId = 2
                    },
                    new Product {
                        Name = "Nanglo Croissant - 300gm (5Pcs)", Description = "", Price = 90.00m, CategoryId = 2
                    },
                    new Product {
                        Name = "Trisara Bakery Mini Chocolate Doughnut, 4piece", Description = "Small portions of chocolate or cocoa is beneficial for heart health.", Price = 130.00m, CategoryId = 2
                    },

                    new Product {
                        Name = "Amul Butter-200gm", Description = "Spread on Bread, Parantha, Roti, Nans, Sandwiches", Price = 255.00m, CategoryId = 3
                    },
                    new Product {
                        Name = "Amul Butter-500gm", Description = "Spread on Bread, Parantha, Roti, Nans, Sandwiches", Price = 620.00m, CategoryId = 3
                    },
                    new Product {
                        Name = "Vegan Dairy Pumpkin Seed Butter, 200ml", Description = "Pumpkin seed butter is a great source of zinc and magnesium", Price = 600.00m, CategoryId = 3
                    },
                    new Product {
                        Name = "Ferments Almond Butter, 190gm", Description = "Almond butter is high in monounsaturated fats.", Price = 775.00m, CategoryId = 3
                    },
                    new Product {
                        Name = "DDC Yak Cheese - 500 gm", Description = "Local DDC Cheese", Price = 845.00m, CategoryId = 3
                    },
                    new Product {
                        Name = "Amul Yummy Plain Cheese Spreed, 200gm", Description = "Amul Cheese Spread - Yummy Plain is a good supply of calcium and milk proteins.", Price = 175.00m, CategoryId = 3
                    },

                    new Product {
                        Name = "Weikfield Baking Soda, 100gm", Description = "Baking soda is a magical ingredient which works wonderfully with a batter of khaman, dhokla or idli.", Price = 52.00m, CategoryId = 4
                    },
                    new Product {
                        Name = "Blue Cow Condensed Milk - 390 gms", Description = "Bluecow Condened Milk is an establish brand in Nepal used by the top bakeries and hotels", Price = 190.00m, CategoryId = 4
                    },
                    new Product {
                        Name = "Kent Syrup Caramel, 624 gm", Description = "", Price = 390.00m, CategoryId = 4
                    },
                    new Product {
                        Name = "Weikfield Cocoa Powder, 50gm", Description = "Makes delicious and flavourful chocolate sauces, cakes and other chocolate desserts", Price = 109.00m, CategoryId = 4
                    },
                    new Product {
                        Name = "American Garden Strawberry Syrup-680gm", Description = "Our strawberry syrup adds a hint of sweetness and freshness when drizzled over any dessert!", Price = 575.00m, CategoryId = 4
                    },
                    new Product {
                        Name = "Morde Compound White - 500 gms", Description = "Morde White Compound is a vegetable fat based chocolate", Price = 398.00m, CategoryId = 4
                    },

                    new Product {
                        Name = "McCain French Fries, Favorita 9mm-2.5kg", Description = "McCain offers this pack of frozen French fries", Price = 935.00m, CategoryId = 5
                    },
                    new Product {
                        Name = "McCain Smiles-415gm", Description = "McCain Smiles are appetizing delicacies that are made up of mashed potatoes", Price = 297.00m, CategoryId = 5
                    },
                    new Product {
                        Name = "Golden Fresh Ready To Cook Veg Momo-40Pc", Description = "Frozen Momo", Price = 400.00m, CategoryId = 5
                    },
                    new Product {
                        Name = "European Bakery Veg Momo - 10 Pcs", Description = "Frozen Momo", Price = 180.00m, CategoryId = 5
                    },
                    new Product {
                        Name = "McCain Super Wedges-400gm", Description = "McCain Super Wedges are crispy coated potatoes", Price = 297.00m, CategoryId = 5
                    },

                    new Product {
                        Name = "Norsk Sjomat Norwegian Smoked Salmon, 200 g", Description = "", Price = 1550.00m, CategoryId = 6
                    },
                    new Product {
                        Name = "Urban Food Medium Prawns - 500 gms", Description = "", Price = 1000.00m, CategoryId = 6
                    },
                    new Product {
                        Name = "Nina & Hager Frozen Trout - Per KG", Description = "", Price = 1400.00m, CategoryId = 6
                    },
                    new Product {
                        Name = "Golden Fresh Prawn 16/20 ,1kg", Description = "", Price = 2100.00m, CategoryId = 6
                    },
                    new Product {
                        Name = "Gourmet Vienna Pork Ribs- Per Kg", Description = "", Price = 1080.00m, CategoryId = 6
                    },
                    new Product {
                        Name = "Gourmet Vienna Pork Slice-200gm", Description = "", Price = 310.00m, CategoryId = 6
                    },

                    new Product {
                        Name = "Kiwi, 1kg", Description = "", Price = 680.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Apple ( Fuzi ), 1kg", Description = "", Price = 280.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Avocado, 1kg", Description = "Avocados are oval shaped fruits with a thick green and a bumpy, leathery outer skin.", Price = 520.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Pomegranate, 1kg", Description = "", Price = 360.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Green Apple, 1kg", Description = "", Price = 520.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Mousam, 1kg", Description = "", Price = 220.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "Guava, 1kg", Description = "", Price = 130.00m, CategoryId = 7
                    },
                    new Product {
                        Name = "American Strawberry, 500gm", Description = "", Price = 600.00m, CategoryId = 7
                    },

                    new Product {
                        Name = "Comfort Fabric Conditioner (Sense of Pleasure)-2ltr", Description = "", Price = 890.00m, CategoryId = 8
                    },
                    new Product {
                        Name = "Comfort Fabric Conditioner(Touch of Love)-2ltr", Description = "Comfort Fabric Conditioner keep your clothes from wearing out too soon.", Price = 850.00m, CategoryId = 8
                    },
                    new Product {
                        Name = "Tide Bar, 250gm (Pack of 3)", Description = "New Tide + with Extra Power detergent, now with the added Power of Bar", Price = 105.00m, CategoryId = 8
                    },
                    new Product {
                        Name = "Surf Excel Stain Eraser Bar - 250 g", Description = "Removes tough stains such as tea, coffee, turmeric, curry, ketchup", Price = 47.00m, CategoryId = 8
                    },
                    new Product {
                        Name = "Surf Excel Matic Top Load Detergent Powder, 1 kg", Description = "Tough stain removal in machine with Surf excel matic", Price = 360.00m, CategoryId = 8
                    },
                    new Product {
                        Name = "Ariel Matic Front Load, 1kg", Description = "Best used for front load fully automatic washing machines", Price = 400.00m, CategoryId = 8
                    },

                    new Product {
                        Name = "Paseo Toilet Roll 200's 4Ply Dolphin- 10rolls", Description = "", Price = 870.00m, CategoryId = 9
                    },
                    new Product {
                        Name = "Paseo Elegant Toilet Roll 280's, 3Ply-4roll", Description = "Toilet Rolls: Paseo Elegant 3 Ply Bathroom Tissue 4 Roll 280 Sheet", Price = 380.00m, CategoryId = 9
                    },
                    new Product {
                        Name = "Paseo Toilet Roll 300's 3Ply-8roll", Description = "Hygenic, soft and natural", Price = 830.00m, CategoryId = 9
                    },

                    new Product {
                        Name = "Newlook Suncontrol spf 50 for Normal & Dry skin-100ml", Description = "NEWLOOK’s Daily Sun Control PA+++ SPF-50", Price = 460.00m, CategoryId = 10
                    },
                    new Product {
                        Name = "Lifebuoy Total - 95gm", Description = "", Price = 35.00m, CategoryId = 10
                    },
                    new Product {
                        Name = "Dettol Soap Regular 125gm (Buy 4 and Get 1 Free)", Description = "", Price = 320.00m, CategoryId = 10
                    },
                    new Product {
                        Name = "Naturo Earth Pink Salt Soap For Face And Body, 100gm", Description = "Naturo Earth’s Pink Salt Soap is infused with Himalayan Pink Salt", Price = 300.00m, CategoryId = 10
                    },
                    new Product {
                        Name = "Head & Shoulder Smooth And Silky Shampoo 720ml", Description = "", Price = 690.00m, CategoryId = 10
                    },

                    new Product {
                        Name = "Black & Green Extra Virgin Avocado Oil, 220ml", Description = "", Price = 2500.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Juas Grass Fed Ghee-1000ml", Description = "Raw free range organic pastured ghee. No salt, sugar or preservatives added.", Price = 1750.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Baby Dove Rich Moisture Head to Toe Wash, 400 ml", Description = "A tear-free and hypoallergenic baby wash and shampoo that helps moisturise your baby’s delicate skin to keep it soft.", Price = 425.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Johnson & Johnson Baby Shampoo No More Tears, 100ml", Description = "Johnson's Baby shampoo is as gentle to the eyes as pure water", Price = 144.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Kennel Adult Dog Food Pouch 1.5Kg", Description = "Shinier coats, Healthier skin...", Price = 475.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "BonaCibo Adult Lamb & Rice, 15kg", Description = "", Price = 5500.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Alpha Electric Kettle Stainless Steel Cordless Jug-2Ltr", Description = "", Price = 730.00m, CategoryId = 11
                    },
                    new Product {
                        Name = "Baltra Prima Induction Cooker", Description = "2000W Energy Saving", Price = 4400.00m, CategoryId = 11
                    },
                };

                foreach (Product p in products)
                {
                    context.Products.Add(p);
                }
                context.SaveChanges();
            }



            if (!context.Customers.Any())
            {
                var customers = new Customer[]
                {
                    new Customer {
                        Name = "Reiko Bridewell", MemberNumber = "12160609"
                    },
                    new Customer {
                        Name = "Ruben Ketchaside", MemberNumber = "23665561", Phone = "6039991683", Email = "*****@*****.**"
                    },
                    new Customer {
                        Name = "Jilly Bendall", MemberNumber = "60673715", MemberType = "Bronze", Phone = "1825693497", Address = "134 Blackbird Hill", Email = "*****@*****.**"
                    },
                    new Customer {
                        Name = "Maritsa Wildber	", MemberNumber = "20697860", MemberType = "Bronze", Phone = "3661740034", Address = "4780 2nd Circle", Email = "*****@*****.**"
                    },
                    new Customer {
                        Name = "Winni Di Iorio", MemberNumber = "55966772", MemberType = "Gold", Phone = "6499054605", Address = "902 Pawling Street", Email = "*****@*****.**"
                    },
                    new Customer {
                        Name = "Kissiah Gaitone", MemberNumber = "56339888"
                    },
                    new Customer {
                        Name = "Gabriell Bartolozzi", MemberNumber = "96900296", Phone = "7412745335", Email = "*****@*****.**"
                    },
                    new Customer {
                        Name = "Feodor Hansod", MemberNumber = "40625989", Phone = "4558027879", Email = "*****@*****.**"
                    },
                };

                foreach (Customer c in customers)
                {
                    context.Customers.Add(c);
                }
                context.SaveChanges();
            }



            if (!context.Stocks.Any())
            {
                var stocks = new Stock[]
                {
                    new Stock {
                        Id = 1, Quantity = 12
                    },
                    new Stock {
                        Id = 2, Quantity = 10
                    },
                    new Stock {
                        Id = 3, Quantity = 10
                    },
                    new Stock {
                        Id = 4, Quantity = 5
                    },
                    new Stock {
                        Id = 7, Quantity = 4
                    },
                    new Stock {
                        Id = 8, Quantity = 15
                    },
                    new Stock {
                        Id = 9, Quantity = 20
                    },
                    new Stock {
                        Id = 10, Quantity = 8
                    },
                    new Stock {
                        Id = 11, Quantity = 22
                    },
                    new Stock {
                        Id = 12, Quantity = 25
                    },
                    new Stock {
                        Id = 13, Quantity = 50
                    },
                    new Stock {
                        Id = 14, Quantity = 46
                    },
                    new Stock {
                        Id = 15, Quantity = 35
                    },
                    new Stock {
                        Id = 16, Quantity = 23
                    },
                    new Stock {
                        Id = 17, Quantity = 22
                    },
                    new Stock {
                        Id = 18, Quantity = 16
                    },
                    new Stock {
                        Id = 19, Quantity = 19
                    },
                    new Stock {
                        Id = 21, Quantity = 12
                    },
                    new Stock {
                        Id = 22, Quantity = 22
                    },
                    new Stock {
                        Id = 25, Quantity = 30
                    },
                    new Stock {
                        Id = 26, Quantity = 21
                    },
                    new Stock {
                        Id = 27, Quantity = 26
                    },
                    new Stock {
                        Id = 28, Quantity = 16
                    },
                    new Stock {
                        Id = 29, Quantity = 6
                    },
                    new Stock {
                        Id = 30, Quantity = 36
                    },
                    new Stock {
                        Id = 32, Quantity = 33
                    },
                    new Stock {
                        Id = 33, Quantity = 22
                    },
                    new Stock {
                        Id = 35, Quantity = 11
                    },
                    new Stock {
                        Id = 37, Quantity = 2
                    },
                    new Stock {
                        Id = 39, Quantity = 26
                    },
                    new Stock {
                        Id = 42, Quantity = 37
                    },
                    new Stock {
                        Id = 45, Quantity = 24
                    },
                    new Stock {
                        Id = 46, Quantity = 15
                    },
                    new Stock {
                        Id = 47, Quantity = 16
                    },
                    new Stock {
                        Id = 48, Quantity = 15
                    },
                    new Stock {
                        Id = 49, Quantity = 11
                    },
                    new Stock {
                        Id = 50, Quantity = 18
                    },
                    new Stock {
                        Id = 52, Quantity = 32
                    },
                    new Stock {
                        Id = 53, Quantity = 19
                    },
                    new Stock {
                        Id = 55, Quantity = 22
                    },
                    new Stock {
                        Id = 57, Quantity = 27
                    },
                    new Stock {
                        Id = 59, Quantity = 26
                    },
                    new Stock {
                        Id = 60, Quantity = 32
                    },
                    new Stock {
                        Id = 61, Quantity = 12
                    },
                    new Stock {
                        Id = 62, Quantity = 16
                    },
                    new Stock {
                        Id = 63, Quantity = 19
                    },
                    new Stock {
                        Id = 65, Quantity = 14
                    },
                };

                foreach (Stock s in stocks)
                {
                    context.Stocks.Add(s);
                }
                context.SaveChanges();
            }

            if (!context.Sales.Any())
            {
                var sales = new Sales[]
                {
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 15), CustomerId = 1
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 8), CustomerId = 7
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 12), CustomerId = 4
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 3, 29), CustomerId = 2
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 3, 30), CustomerId = 2
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 2, 5), CustomerId = 5
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 21), CustomerId = 3
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 25), CustomerId = 6
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 4, 26), CustomerId = 2
                    },
                    new Sales {
                        SalesDate = new DateTime(2021, 2, 3), CustomerId = 7
                    },
                };

                foreach (Sales s in sales)
                {
                    context.Sales.Add(s);
                }
                context.SaveChanges();
            }

            if (!context.SalesLineItems.Any())
            {
                var salesLineItems = new SalesLineItem[]
                {
                    new SalesLineItem {
                        Quantity = 2, ProductId = 5, SalesId = 1
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 10, SalesId = 2
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 12, SalesId = 2
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 50, SalesId = 3
                    },
                    new SalesLineItem {
                        Quantity = 10, ProductId = 14, SalesId = 3
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 25, SalesId = 3
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 31, SalesId = 4
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 42, SalesId = 4
                    },
                    new SalesLineItem {
                        Quantity = 5, ProductId = 16, SalesId = 5
                    },
                    new SalesLineItem {
                        Quantity = 12, ProductId = 17, SalesId = 5
                    },
                    new SalesLineItem {
                        Quantity = 3, ProductId = 8, SalesId = 5
                    },
                    new SalesLineItem {
                        Quantity = 6, ProductId = 61, SalesId = 6
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 55, SalesId = 6
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 34, SalesId = 7
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 56, SalesId = 7
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 23, SalesId = 7
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 29, SalesId = 7
                    },
                    new SalesLineItem {
                        Quantity = 3, ProductId = 19, SalesId = 8
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 18, SalesId = 9
                    },
                    new SalesLineItem {
                        Quantity = 5, ProductId = 4, SalesId = 9
                    },
                    new SalesLineItem {
                        Quantity = 2, ProductId = 2, SalesId = 9
                    },
                    new SalesLineItem {
                        Quantity = 5, ProductId = 39, SalesId = 10
                    },
                    new SalesLineItem {
                        Quantity = 1, ProductId = 58, SalesId = 10
                    },
                };

                foreach (SalesLineItem s in salesLineItems)
                {
                    context.SalesLineItems.Add(s);
                }
                context.SaveChanges();
            }

            if (!context.Purchases.Any())
            {
                var purchases = new Purchase[]
                {
                    new Purchase {
                        PurchaseDate = new DateTime(2020, 8, 12), Vendor = "ABC Suppliers"
                    },
                    new Purchase {
                        PurchaseDate = new DateTime(2020, 12, 1), Vendor = "Zero Distributors"
                    },
                    new Purchase {
                        PurchaseDate = new DateTime(2021, 1, 10), Vendor = "OK Pvt. Ltd."
                    },
                    new Purchase {
                        PurchaseDate = new DateTime(2021, 2, 9), Vendor = "Index Distributors"
                    },
                    new Purchase {
                        PurchaseDate = new DateTime(2021, 3, 15), Vendor = "OK Pvt. Ltd."
                    },
                };

                foreach (Purchase p in purchases)
                {
                    context.Purchases.Add(p);
                }
                context.SaveChanges();
            }

            if (!context.PurchaseLineItems.Any())
            {
                var purchaseLineItems = new PurchaseLineItem[]
                {
                    new PurchaseLineItem {
                        ProductId = 1, Quantity = 30, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 2, Quantity = 20, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 3, Quantity = 15, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 4, Quantity = 6, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 7, Quantity = 9, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 8, Quantity = 28, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 9, Quantity = 14, PurchaseId = 1
                    },
                    new PurchaseLineItem {
                        ProductId = 10, Quantity = 34, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 11, Quantity = 22, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 12, Quantity = 26, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 13, Quantity = 59, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 14, Quantity = 99, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 15, Quantity = 65, PurchaseId = 2
                    },
                    new PurchaseLineItem {
                        ProductId = 16, Quantity = 53, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 17, Quantity = 29, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 18, Quantity = 46, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 19, Quantity = 29, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 21, Quantity = 19, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 22, Quantity = 25, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 25, Quantity = 32, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 26, Quantity = 26, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 27, Quantity = 22, PurchaseId = 3
                    },
                    new PurchaseLineItem {
                        ProductId = 28, Quantity = 18, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 29, Quantity = 69, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 30, Quantity = 47, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 32, Quantity = 53, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 33, Quantity = 42, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 35, Quantity = 17, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 37, Quantity = 23, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 39, Quantity = 29, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 42, Quantity = 56, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 45, Quantity = 28, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 46, Quantity = 19, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 47, Quantity = 26, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 48, Quantity = 35, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 49, Quantity = 17, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 50, Quantity = 38, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 52, Quantity = 39, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 53, Quantity = 29, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 55, Quantity = 23, PurchaseId = 4
                    },
                    new PurchaseLineItem {
                        ProductId = 57, Quantity = 29, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 59, Quantity = 46, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 60, Quantity = 36, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 61, Quantity = 22, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 62, Quantity = 20, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 63, Quantity = 37, PurchaseId = 5
                    },
                    new PurchaseLineItem {
                        ProductId = 65, Quantity = 25, PurchaseId = 5
                    },
                };

                foreach (PurchaseLineItem p in purchaseLineItems)
                {
                    context.PurchaseLineItems.Add(p);
                }
                context.SaveChanges();
            }
        }
Esempio n. 60
0
        public Category Post([FromBody] Category category)
        {
            _repository.Save(category);

            return(category);
        }