Exemplo n.º 1
0
        public List <question> getQuestionsByCathegory(int id)
        {
            Cathegory cat = db.Cathegories.Find(id);

            List <Question> questions = (from q in db.Questions
                                         where q.cathegory.id == id && q.answerText != null
                                         select q).ToList();
            List <question> list = new List <question>();

            foreach (Question q in questions)
            {
                question q1 = new question()
                {
                    id           = q.id,
                    questionText = q.questionText,
                    answerText   = q.answerText,
                    cathegory    = cat.name
                };
                list.Add(q1);
            }

            /*List<question> questions = getAllQuestions();
             * for (int i = 0; i < questions.Count; i++)
             * {
             *  if (questions[i].cathegory.Equals(cathegory.name))
             *  {
             *      continue;
             *  }
             *  questions.RemoveAt(i+1);
             * }*/
            return(list);
        }
Exemplo n.º 2
0
 public bool DeleteCathegory(int id)
 {
     using (ManaCenaEntities context = new ManaCenaEntities())
     {
         var rec = new Cathegory {
             Id = id
         };
         context.Entry(rec).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
     return(true);
 }
Exemplo n.º 3
0
        public async Task <ActionResult <Cathegory> > Post(
            [FromServices] DataContext context,
            [FromBody] Cathegory model)
        {
            if (ModelState.IsValid)
            {
                context.Cathegories.Add(model);
                await context.SaveChangesAsync();

                return(model);
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 4
0
 public bool EditCathegory(Cathegory rec)
 {
     using (ManaCenaEntities context = new ManaCenaEntities())
     {
         context.Cathegories.Add(rec);
         if (rec.Id > 0)
         {
             context.Entry(rec).State = System.Data.Entity.EntityState.Modified;
         }
         else
         {
             context.Entry(rec).State = System.Data.Entity.EntityState.Added;
         }
         context.SaveChanges();
     }
     return(true);
 }
Exemplo n.º 5
0
        static Questionary()
        {
            var questionModels = JsonConvert.DeserializeObject <Question[]>(Encoding.UTF8.GetString(Resources.Questions));

            Questions = new QuestionVM[120];
            for (int i = 0; i < 120; i++)
            {
                Questions[i] = new QuestionVM(questionModels[i]);
            }

            TableManners         = Questions.AtIndexes(0, 1, 17, 18, 33, 50, 68, 91, 92, 108).ToArray();
            MotorSkills          = Questions.AtIndexes(2, 3, 19, 34, 35, 51, 69, 70, 93, 109).ToArray();
            ToiletAndWashing     = Questions.AtIndexes(4, 20, 21, 36, 37, 52, 53, 71, 94, 110).ToArray();
            DressingUp           = Questions.AtIndexes(5, 6, 22, 23, 38, 54, 72, 73, 95, 111).ToArray();
            Language             = Questions.AtIndexes(7, 8, 24, 25, 39, 55, 56, 74, 96, 112).ToArray();
            Differentiation      = Questions.AtIndexes(9, 26, 40, 57, 58, 75, 76, 77, 97, 113).ToArray();
            NumbersAndSizes      = Questions.AtIndexes(10, 27, 41, 42, 59, 78, 79, 80, 98, 114).ToArray();
            PencilAndPaperSkills = Questions.AtIndexes(11, 28, 43, 60, 81, 82, 99, 100, 101, 115).ToArray();
            Playing      = Questions.AtIndexes(12, 29, 44, 45, 61, 62, 63, 83, 102, 116).ToArray();
            Housework    = Questions.AtIndexes(13, 30, 46, 64, 84, 85, 86, 103, 104, 117).ToArray();
            ManualSkills = Questions.AtIndexes(14, 15, 31, 47, 48, 65, 66, 87, 105, 118).ToArray();
            Agility      = Questions.AtIndexes(16, 32, 49, 67, 88, 89, 90, 106, 107, 119).ToArray();

            SubcathegoryName = new Dictionary <QuestionVM[], string>();

            SubcathegoryName.Add(TableManners, Resources.TableMannersSubcathegoryName);
            SubcathegoryName.Add(MotorSkills, Resources.MotorSkillsSubcathegoryName);
            SubcathegoryName.Add(ToiletAndWashing, Resources.ToiletAndWashingSubcathegoryName);
            SubcathegoryName.Add(DressingUp, Resources.DressingUpSubcathegoryName);
            SubcathegoryName.Add(Language, Resources.LanguageSubcathegoryName);
            SubcathegoryName.Add(Differentiation, Resources.DifferentiationSubcathegoryName);
            SubcathegoryName.Add(NumbersAndSizes, Resources.NumbersAndSizesSubcathegoryName);
            SubcathegoryName.Add(PencilAndPaperSkills, Resources.PencilAndPaperSkillsSubcathegoryName);
            SubcathegoryName.Add(Playing, Resources.PlayingSubcathegoryName);
            SubcathegoryName.Add(Housework, Resources.HouseworkSubcathegoryName);
            SubcathegoryName.Add(ManualSkills, Resources.ManualSkillsSubcathegoryName);
            SubcathegoryName.Add(Agility, Resources.AgilitySubcathegoryName);

            SelfHelp      = new Cathegory(TableManners, MotorSkills, ToiletAndWashing, DressingUp);
            Communication = new Cathegory(Language, Differentiation, NumbersAndSizes, PencilAndPaperSkills);
            Socialization = new Cathegory(Playing, Housework);
            Occupation    = new Cathegory(ManualSkills, Agility);
        }
Exemplo n.º 6
0
        // rekurzivno ucitavanje csv datoteke
        public void FillCategories(List <Cathegory> kategorije, Cathegory cat)
        {
            if (cat.ParentID == null)
            {
                kategorije.Add(cat);
                return;
            }

            foreach (var c in kategorije)
            {
                if (c.CathegoryID == cat.ParentID)
                {
                    c.Children.Add(cat);
                    return;
                }
                else
                {
                    FillCategories(c.Children, cat);
                }
            }
        }
Exemplo n.º 7
0
        // upload i ucitavanje datoteke u listu kategorija
        public ActionResult UploadFile(HttpPostedFileBase uploadedFile)
        {
            if (uploadedFile == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            try
            {
                kategorije.Clear();

                StreamReader sr = new StreamReader(uploadedFile.InputStream);

                // sadrzaj csv datoteke
                string csvData = sr.ReadToEnd();

                // redci
                foreach (string row in csvData.Split('\n'))
                {
                    if (!string.IsNullOrEmpty(row))
                    {
                        Cathegory cat = new Cathegory
                        {
                            CathegoryID = Convert.ToInt32(row.Split(',')[0]),
                            ParentID    = !(row.Split(',')[1]).Equals("") ? Convert.ToInt32(row.Split(',')[1]) : (int?)null,
                            Name        = row.Split(',')[2],
                            Children    = new List <Cathegory>()
                        };
                        // poziv rekurzivne metode za svaki novi Cathegory objekt.
                        // metoda dodaje novi objekt u Children listu od Parent kategorije, a ako objekt nema ParentID onda ga dodaje u listu kategorije "root"
                        FillCategories(kategorije, cat);
                    }
                }
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 8
0
        public ActionResult Create(FormCollection collection)   //OK
        {
            int IdThemes      = 0;
            int IdCathegories = 0;
            int IdAuthor      = 0;
            int IdPress       = 0;

            try
            {
                if (collection["newTheme"] != "")
                {
                    Themes t1 = new Themes()
                    {
                        Name = collection["newThemes"]
                    };
                    db.Themes.Add(t1);
                    db.SaveChanges();
                    IdThemes = t1.Id;
                }
                else
                {
                    IdThemes = Convert.ToInt32(collection["Id_Themes"]);
                }

                if (collection["newCathegory"] != "")
                {
                    Cathegory c1 = new Cathegory()
                    {
                        Name = collection["newCathegory"]
                    };
                    db.Cathegory.Add(c1);
                    db.SaveChanges();
                    IdCathegories = c1.Id;
                }
                else
                {
                    IdCathegories = Convert.ToInt32(collection["Id_Cathegories"]);
                }

                if (collection["newAuthorFName"] != "" && collection["newAuthorLName"] != "")
                {
                    Authors a1 = new Authors()
                    {
                        FirstName = collection["newAuthorFName"],
                        LastName  = collection["newAuthorLName"]
                    };
                    db.Authors.Add(a1);
                    db.SaveChanges();
                    IdAuthor = a1.Id;
                }
                else
                {
                    IdAuthor = Convert.ToInt32(collection["Id_Author"]);
                }

                if (collection["newPress"] != "")
                {
                    Press p1 = new Press()
                    {
                        Name = collection["newPress"]
                    };
                    db.Press.Add(p1);
                    db.SaveChanges();
                    IdPress = p1.Id;
                }
                else
                {
                    IdPress = Convert.ToInt32(collection["Id_Press"]);
                }

                Books data = new Books()
                {
                    Name         = collection["Name"],
                    Pages        = Convert.ToInt32(collection["Pages"]),
                    YearPress    = Convert.ToInt32(collection["YearPress"]),
                    Quantity     = Convert.ToInt32(collection["Quantity"]),
                    Id_Themes    = IdThemes,
                    Id_Cathegory = IdCathegories,
                    Id_Author    = IdAuthor,
                    Id_Press     = IdPress,
                    Comment      = collection["Comment"]
                };
                db.Books.Add(data);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 9
0
 public Product(Cathegory cat, string description, long price, int creatorId)
     : base(cat, description, price, creatorId, nameof(FreelancerCorpDbContext.Products))
 {
 }
Exemplo n.º 10
0
 public JobOffer(Cathegory cat, string description, long price, int creatorId, DateTime startDate, DateTime endDate)
     : base(cat, description, price, creatorId, nameof(FreelancerCorpDbContext.Offers))
 {
     StartDate = startDate;
     EndDate   = endDate;
 }