Пример #1
0
        public Advert(string advertName,
                      string description,
                      int workHours,
                      string address,
                      string phoneNumber,
                      string emailAddress,
                      decimal hourPayment,
                      decimal monthlyPayment,
                      City city,
                      MainCategory mainCategory)
        {
            this.AdvertName = advertName;

            this.Description = description;

            this.WorkHours = workHours;

            this.Address = address;

            this.PhoneNumber = phoneNumber;

            this.EmailAddress = emailAddress;

            this.HourPayment = hourPayment;

            this.MonthlyPayment = monthlyPayment;

            this.City = city;

            this.MainCategory = mainCategory;
        }
Пример #2
0
        public ActionResult AddorEditMainCategory(MainCategory mainCategory)
        {
            try
            {
                if (mainCategory.imgFile != null)
                {
                    string filename  = Path.GetFileNameWithoutExtension(mainCategory.imgFile.FileName);
                    string extension = Path.GetExtension(mainCategory.imgFile.FileName);
                    filename = filename + DateTime.Now.ToString("yymmssfff") + extension;
                    string fileRelativePath = "~/App_Files/Images/" + filename;

                    Uri baseuri      = new Uri(Request.Url.ToString());
                    Uri fileFullPath = new Uri(baseuri, VirtualPathUtility.ToAbsolute(fileRelativePath));
                    fileFullPath.ToString().Trim('{'); fileFullPath.ToString().Trim('}');
                    mainCategory.img = fileFullPath.ToString();
                    mainCategory.imgFile.SaveAs(Path.Combine(Server.MapPath("~/App_Files/Images/"), filename));
                }


                Abeced_Data.Abeced.Data.MainCategory MainCats = new Abeced_Data.Abeced.Data.MainCategory
                {
                    name        = mainCategory.name,
                    description = mainCategory.description,
                    img         = mainCategory.img,
                };

                Repositery _repo = new Repositery();
                _repo.SaveMainCategory(MainCats);
                return(Json(new { returnmsg = "Success" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public async void CreateCategoryAsync_ShouldCreateCategory()
        {
            var options = new DbContextOptionsBuilder <TechAndToolsDbContext>()
                          .UseInMemoryDatabase(databaseName: "CreateCategoryAsync_ShouldCreateCategory")
                          .Options;

            var context = new TechAndToolsDbContext(options);

            context.Database.EnsureDeleted();

            var mainCategory = new MainCategory
            {
                Id   = 1,
                Name = "PC"
            };

            await context.MainCategories.AddAsync(mainCategory);

            await context.SaveChangesAsync();

            ICategoryService categoryService = new CategoryService(context);

            await categoryService.CreateCategoryAsync(new CategoryServiceModel { Name = "category1", MainCategoryId = 1 });

            await categoryService.CreateCategoryAsync(new CategoryServiceModel { Name = "category2", MainCategoryId = 1 });

            int expectedResult = 2;
            int actualResult   = context.Categories.Count();

            Assert.Equal(expectedResult, actualResult);
        }
Пример #4
0
        public async Task <ActionResult <MainCategory> > PostMainCategory(MainCategory mainCategory)
        {
            _context.MainCategories.Add(mainCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMainCategory", new { id = mainCategory.Id }, mainCategory));
        }
Пример #5
0
        private void Mainser_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int lang       = 1;
            int clientType = (int)PhoneApplicationService.Current.State["clientType"];

            lang = (int)PhoneApplicationService.Current.State["language"];

            index        = (sender as ListPicker).SelectedIndex;
            selectedItem = (sender as ListPicker).SelectedItem as MainCategory;



            if (index != -1)
            {
                if (!IsInitSer)
                {
                    client.getServiceAsync(selectedItem.Id, lang);
                    client.getServiceCompleted += client_getServiceCompleted;
                    IsInitSer = true;
                }
                if (!IsInitSub)
                {
                    client.getSubServiceAsync(selectedItem.Id, lang);
                    client.getSubServiceCompleted += client_getSubServiceCompleted;
                    IsInitSub = true;
                }
            }
        }
Пример #6
0
        public static List <Advert> GetAdvertsByCategory(WorkHireContext dbContext,
                                                         MainCategory category)
        {
            _db = dbContext;

            return(_db.Adverts.Where(a => a.MainCategory == category).ToList());
        }
Пример #7
0
        public async Task <IActionResult> PutMainCategory(string id, MainCategory mainCategory)
        {
            if (id != mainCategory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(mainCategory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MainCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #8
0
        public IHttpActionResult PutMainCategory(int id, MainCategory mainCategory)
        {
            if (id != mainCategory.MainCategoryId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #9
0
        public ActionResult New_Sub()
        {
            model = new TypeASPX();
            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();

            using (DataTable dt = db.Select("SELECT [id_MC],[MCName]FROM [tbl_Product_MainCategory] WHERE ISDESABLED=0 AND ISDelete=0"))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    data_cat = new MainCategory();


                    data_cat.id_MC  = dt.Rows[i]["id_MC"].ToString();
                    data_cat.MCName = dt.Rows[i]["MCName"].ToString();
                    list_cat.Add(data_cat);
                }
                ViewBag.Sub = list_cat;
            };


            if (Session["edit_Sub"] != null)
            {
                model         = (TypeASPX)Session["edit_Sub"];
                ViewBag.model = model;
            }
            else
            {
                ViewBag.model = model;
            }

            return(View());
        }
Пример #10
0
        //////////////////////////////////////////////////// list cat : get
        public ActionResult table_Cat()
        {
            string query_type;

            PDBC db = new PDBC("PandaMarketCMS", true);

            db.Connect();
            query_type = "SELECT [id_MC],[id_PT],[MCName],[ISDESABLED],[ISDelete],(select PTname from [tbl_Product_Type]where [id_PT]=[tbl_Product_MainCategory].[id_PT] ) as 'name_PT',( select count (id_SC) from [tbl_Product_SubCategoryOptionKey] where id_SC in( select id_SC from[tbl_Product_SubCategory] where id_MC =[tbl_Product_MainCategory].[id_MC] ))  as 'count' FROM [tbl_Product_MainCategory]";
            // query_type = "select [id_PT] ,[PTname],[ISDESABLED],[ISDelete],( select count (id_SC) from [dbo].[tbl_Product_SubCategoryOptionKey] where id_SC in ( select id_SC from [dbo].[tbl_Product_SubCategory] where id_MC in ( select id_MC from [dbo].[tbl_Product_MainCategory] where [id_PT]=[dbo].[tbl_Product_Type].[id_PT] )))  as 'count' from [dbo].[tbl_Product_Type]";
            using (DataTable dt = db.Select(query_type))
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    data_cat = new MainCategory();

                    data_cat.id_MC      = dt.Rows[i]["id_MC"].ToString();
                    data_cat.id_PT      = dt.Rows[i]["name_PT"].ToString();
                    data_cat.MCName     = dt.Rows[i]["MCName"].ToString();
                    data_cat.ISDelete   = dt.Rows[i]["ISDelete"].ToString();
                    data_cat.ISDESABLED = dt.Rows[i]["ISDESABLED"].ToString();
                    data_cat.count      = dt.Rows[i]["count"].ToString();
                    list_cat.Add(data_cat);
                }
                ViewBag.Cats = list_cat;
            }

            return(View());
        }
Пример #11
0
    void retrieveCategories()
    {
        string targetUri = serverUriPath + TaskManagerAccessUriPath;

        targetUri += ("categories/all/" + user.Level_pet + "/" + user.CurrentStage + "/");

        GET(targetUri);
        string response = wwwResquest.text;

        List <Category> categories = new List <Category> ();

        if (response != "")
        {
            string[] categoryObjects = response.Split(';');
            foreach (string sCategory in categoryObjects)
            {
                string[]     values   = sCategory.Split('.');
                MainCategory category = new MainCategory();
                category.Id           = int.Parse(values[0]);
                category.Name         = values[1];
                category.Stage        = int.Parse(values[2]);
                category.InitialValue = int.Parse(values[3]);
                category.FinalValue   = int.Parse(values[4]);
                category.Level        = int.Parse(values[5]);
                category.Available    = bool.Parse(values[6]);

                nextTaskAvailable      = true;
                category.SubCategories = retrieveSubCategories(category, category.Stage);

                categories.Add(category);
            }
        }

        user.Categories = categories;
    }
Пример #12
0
    /*
     * @desc Variable initializations.
     * CurrentStage caught.
     * @see UserInfo
     */
    void variablesInitializations()
    {
        currentStage = 1;
        totalStage   = 10;
        qtyHit       = 0;
        qtyFail      = 0;
        category     = (MainCategory)currentUser.CurrentCategory;
        fase         = category.Stage;

        timeMessage = 4;

        message = "Interaction";
        if (helpMessage == "")
        {
            helpMessage = "Help message";
        }
        else if (endGameMessage == "")
        {
            endGameMessage = "Fim de jogo!";
        }

        previousEugenio = eugenioTexture;

        // flags
        flagHelpMessage           = false;
        flagMessage               = false;
        flagEndGame               = false;
        flagControlMessageEndGame = false;
        flagSound = true;
        flagRectBarDimensionsHasChanged = true;
    }
Пример #13
0
 public ActionResult CreateMainMenu(MainMenu model)
 {
     if (ModelState.IsValid)
     {
         model.IsMenu = true;
         try
         {
             if (_categoryService.GetCategory(model.Code) == null)
             {
                 MainCategory mainCategory = _categoryService.GetMainCategories().Where(m => m.Code == (int)MainCategoryType.Menu).First();
                 model.ParentCategoryCode = mainCategory.Code;
                 _categoryService.CreateCategory(model);
                 _categoryService.SaveCategory();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ModelState.AddModelError("Code", ErrorMessages.CATEGORYCODE_EXIST);
             }
         }
         catch (Exception e)
         {
             ModelState.AddModelError("", e);
         }
     }
     return(View(model));
 }
Пример #14
0
        public async Task <IActionResult> Edit(string id, [Bind("CategoryId,CategoryName")] MainCategory mainCategory)
        {
            if (id != mainCategory.CategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mainCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MainCategoryExists(mainCategory.CategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainCategory));
        }
        public void Configure(EntityTypeBuilder <Author> builder)
        {
            builder.ToTable("Author").HasKey(k => k.Id);

            builder.OwnsOne(p => p.Name, p =>
            {
                p.Property(pp => pp.First).HasColumnName("FirstName").IsRequired().HasMaxLength(50);
                p.Property(pp => pp.Last).HasColumnName("LastName").IsRequired().HasMaxLength(50);
            });

            builder.Property(p => p.DateOfBirth)
            .IsRequired()
            .HasConversion(p => p.Value, p => BirthDate.Create(p).Value);

            builder.Property(p => p.DateOfDeath)
            .HasConversion(p => p.Value, p => DeathDate.Create(p).Value);

            builder.Property(p => p.MainCategory)
            .IsRequired()
            .HasMaxLength(50)
            .HasConversion(p => p.Value, p => MainCategory.Create(p).Value);

            builder.HasMany(p => p.Books).WithOne(p => p.Author)
            .OnDelete(DeleteBehavior.Cascade)
            .Metadata.PrincipalToDependent.SetPropertyAccessMode(PropertyAccessMode.Field);
        }
Пример #16
0
        public void DeleteMainCategory(int id)
        {
            MainCategory mainCategory = db.MainCategories.Find(id);

            db.MainCategories.Remove(mainCategory);
            db.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "MainCategoryId,Name")] MainCategory category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.MainCategories.Add(category);
                    db.SaveChanges();

                    var dbCategory = db.MainCategories.Where(m => m.Name == category.Name).SingleOrDefault();
                    return(RedirectToAction("Index", "Category"));
                }
                else
                {
                    string errMsg = "Something failed, probably validation";
                    var    er     = ModelState.Values.FirstOrDefault();
                    if (er != null && er.Value != null && !String.IsNullOrEmpty(er.Value.AttemptedValue))
                    {
                        errMsg = "\"" + er.Value.AttemptedValue + "\" Does not validate";
                    }
                    return(Json(new { Error = errMsg }));
                }
            } catch (InvalidOperationException ioex)
            {
                if (ioex.Message.Contains("Sequence contains more than one element"))
                {
                    return(Json(new { Error = "Value provided exists in DB, enter a unique value" }));
                }
                return(Json(new { Error = ioex.Message }));
            } catch (Exception ex)
            {
                return(Json(new { Error = ex.Message }));
            }
        }
        public async void CreateMainCategoryAsyncShouldCreateMainCategory()
        {
            var options = new DbContextOptionsBuilder <TechAndToolsDbContext>()
                          .UseInMemoryDatabase(databaseName: "CreateMainCategoryAsyncShouldCreateMainCategory")
                          .Options;

            var context = new TechAndToolsDbContext(options);

            IMainCategoryService mainCategoryService = new MainCategoryService(context);

            await mainCategoryService.CreateAsync(new MainCategoryServiceModel { Name = "PC" });

            await mainCategoryService.CreateAsync(new MainCategoryServiceModel { Name = "Tools" });

            MainCategory first  = context.MainCategories.First();
            MainCategory second = context.MainCategories.Last();

            Assert.Equal(2, context.MainCategories.Count());
            Assert.Equal("PC", first.Name);
            Assert.Equal("Tools", second.Name);
            Assert.NotNull(first);
            Assert.NotNull(first.Categories);
            Assert.NotNull(second);
            Assert.NotNull(second.Categories);
        }
Пример #19
0
 public ActionResult CreateMainCode(MainCategory model)
 {
     if (ModelState.IsValid)
     {
         model.IsMenu = false;
         try
         {
             if (_categoryService.GetCategory(model.Code) == null)
             {
                 _categoryService.CreateCategory(model);
                 _categoryService.SaveCategory();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ModelState.AddModelError("Code", ErrorMessages.CATEGORYCODE_EXIST);
             }
         }
         catch (Exception e)
         {
             ModelState.AddModelError("", e);
         }
     }
     return(View(model));
 }
Пример #20
0
 public void AddOrUpdate(MainCategory mainCategory)
 {
     if (mainCategory == null)
     {
         throw new ArgumentNullException(nameof(mainCategory));
     }
     _categories.AddOrUpdate(mainCategory);
 }
 public void Customize(IFixture fixture)
 {
     fixture.Customizations.Add(new CurrentDateTimeGenerator());
     fixture.Register(() => Name.Create(fixture.Create <string>(), fixture.Create <string>()).Value);
     fixture.Register(() => BirthDate.Create(fixture.Create <DateTimeOffset>().AddDays(-fixture.Create <int>())).Value);
     fixture.Register(() => DeathDate.Create(fixture.Create <DateTimeOffset>().AddDays(-fixture.Create <int>())).Value);
     fixture.Register(() => MainCategory.Create(fixture.Create <string>()).Value);
 }
Пример #22
0
        public Task Handle(CreateMainCategoryCommand command)
        {
            var mainCategory = new MainCategory(command.Title, command.ImageName, command.IsActive);

            _mainCategoryRepository.Add(mainCategory);

            return(Task.CompletedTask);
        }
Пример #23
0
 public IActionResult CreateMainCategories([FromBody] MainCategory newcat)
 {
     if (newcat == null)
     {
         throw new ArgumentNullException();
     }
     return(Ok(new { Status = "Success", MainCategories = _mainCategorySrv.CreateMainCategory(newcat) }));
 }
        public void SetCategoryAsSub(Category category, MainCategory mainCategory)
        {
            ParallelFetch("SubCategory", "Category_");
            DataRow row = ToDataRow(category);

            row["Main_Name"] = mainCategory.Name;
            dataSet.Tables["SubCategory"].Rows.Add(row);
        }
 public MainCategory CreateMainCategory(MainCategory cat)
 {
     if (cat == null)
     {
         throw new ArgumentNullException();
     }
     return(_mainCatRepo.Insert(cat));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            MainCategory mainCategory = db.MainCategories.Find(id);

            db.MainCategories.Remove(mainCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #27
0
        public void Create_MainCategory_Should_Fail_For_EmptyNullValue(string mainCategory)
        {
            //Act
            var result = MainCategory.Create(mainCategory);

            //Assert
            result.IsFailure.Should().BeTrue();
            result.Error.Should().Be("Main Category is required.");
        }
Пример #28
0
 public override string ToString()
 {
     return("物品ID:" + ItemClass + "\n物品名字:" + Name + " \n需求等级: " + RequiredLevel
            + "\n最大叠放数量:" + (MaxStack < 0?"不限":"" + MaxStack)
            + "\n分类:" + SubCategory.Name() + "  " + MainCategory.Name()
            + "\n限制条件" + Feature + "\n职业限制:" + ClassInfoEx.GetClassText(ClassRestriction)
            + (Stat == null?"":"\n" + Stat.ToString())
            + "\n" + Desc);
 }
        public Item[] GetItemsOf(MainCategory mainCategory)
        {
            FetchTable("Item");
            var res = from entry in dataSet.Tables["Item"].AsEnumerable()
                      where entry.Field <string>("MainName") == mainCategory.Name
                      select QuerySelect <Item>(entry);

            return(res.ToArray());
        }
        public void UnSetCategoryAsMain(MainCategory category)
        {
            FetchTable("MainCategory");
            var row = (from entry in dataSet.Tables["MainCategoyr"].AsEnumerable()
                       where entry.Field <string>("Name_") == category.Name
                       select entry).Single();

            dataSet.Tables["MainCategory"].Rows.Remove(row);
        }
Пример #31
0
		public Category (MainCategory parentCategory, string categoryName, int difficulty)
		{
				m_ParentCategory = parentCategory;
				m_CategoryName = categoryName;
				m_Difficulty = difficulty;
		}
Пример #32
0
	/// <summary>
	/// XML LOADER
	/// </summary>
	/// <param name="filename">Filename of the xml file</param>

		public void LoadCategory (string filename)
		{
				TextAsset textAsset = new TextAsset ();
				textAsset = (TextAsset)Resources.Load (filename, typeof(TextAsset));

				if (textAsset != null) {

						XmlDocument xmlDoc = new XmlDocument (); // xmlDoc is the new xml document.
						xmlDoc.LoadXml (GetTextWithoutBOM (textAsset)); // load the file.

						XmlElement root = xmlDoc.DocumentElement;
						XmlNode catName = root.SelectSingleNode ("name");
						XmlNode catParent = root.SelectSingleNode ("parent");

						m_CategoryName = catName.InnerText;
						m_ParentCategory = (MainCategory)Enum.Parse (typeof(MainCategory), catParent.InnerText);

						XmlNodeList correctList = xmlDoc.GetElementsByTagName ("correct");
						XmlNodeList wrongList = xmlDoc.GetElementsByTagName ("wrong");


						m_AnswerList = new List<AnswerCell> ();


						foreach (XmlNode chldNode in correctList) {

								AnswerCell tempcell = new AnswerCell ();

								tempcell.m_AnswerText = chldNode.Attributes ["Text"].Value;
								tempcell.m_Difficulty = Convert.ToInt32(chldNode.Attributes ["Difficulty"].Value);
								tempcell.m_IsCorrect = true;

								m_AnswerList.Add (tempcell);
						}

						foreach (XmlNode chldNode in wrongList) {
				
								AnswerCell tempcell = new AnswerCell ();
				
								tempcell.m_AnswerText = chldNode.Attributes ["Text"].Value;
								tempcell.m_Difficulty = Convert.ToInt32(chldNode.Attributes ["Difficulty"].Value);
								tempcell.m_IsCorrect = false;
				
								m_AnswerList.Add (tempcell);
						}


						
				}
		}