Exemple #1
0
        public UserResultForItem(int userId, TblItems item, DateTime?date)
        {
            _date   = date;
            _userId = userId;
            _item   = item;

            //_pageRank = (int)_page.PageRank;
        }
Exemple #2
0
        public UserResultForItem(int userId, TblItems item, DateTime? date)
        {
            _date = date;
            _userId = userId;
            _item = item;

            //_pageRank = (int)_page.PageRank;
        }
Exemple #3
0
        void Initialize()
        {
            TblCourses course = new TblCourses
            {
                Name = "course"
            };

            ServerModel.DB.Insert(course);

            TblOrganizations organisation = new TblOrganizations
            {
                CourseRef = course.ID,
                Title     = "organisation"
            };

            ServerModel.DB.Insert(organisation);

            TblResources resource = new TblResources
            {
                CourseRef  = course.ID,
                Type       = "bob",
                Identifier = "resource"
            };

            ServerModel.DB.Insert(resource);

            TblItems item = new TblItems
            {
                OrganizationRef = organisation.ID,
                ResourceRef     = resource.ID,
                Title           = "item"
            };

            ServerModel.DB.Insert(item);

            TblLearnerAttempts attempt = new TblLearnerAttempts
            {
                //bug with foreign keys!
            };

            ServerModel.DB.Insert(attempt);

            TblLearnerSessions session = new TblLearnerSessions
            {
                ItemRef           = item.ID,
                LearnerAttemptRef = attempt.ID
            };

            ServerModel.DB.Insert(session);
            currentSession = session;

            TblUsers user = GetUniqueUserForTesting();

            ServerModel.DB.Insert(user);

            sessionID = session.ID;
            userID    = user.ID;
        }
        private void ShowPage(TblItems item)
        {
            PageContent.Controls.Clear();

            TblResources resource = ServerModel.DB.Load <TblResources>((int)item.ResourceRef);
            Control      control  = GetControl(resource, PageContent);

            PageContent.Controls.Add(control);

            InitializeLearnerSession(item.ID);
        }
Exemple #5
0
    void Initialize()
    {
      TblCourses course = new TblCourses
      {
        Name = "course"
      };
      ServerModel.DB.Insert(course);

      TblOrganizations organisation = new TblOrganizations
      {
        CourseRef = course.ID,
        Title = "organisation"
      };
      ServerModel.DB.Insert(organisation);

      TblResources resource = new TblResources
      {
        CourseRef = course.ID,
        Type = "bob",
        Identifier = "resource"
      };
      ServerModel.DB.Insert(resource);

      TblItems item = new TblItems
      {
        OrganizationRef = organisation.ID,
        ResourceRef = resource.ID,
        Title = "item"
      };
      ServerModel.DB.Insert(item);

      TblLearnerAttempts attempt = new TblLearnerAttempts
      {
        //bug with foreign keys!
      };
      ServerModel.DB.Insert(attempt);

      TblLearnerSessions session = new TblLearnerSessions
      {
        ItemRef = item.ID,
        LearnerAttemptRef = attempt.ID
      };
      ServerModel.DB.Insert(session);
      currentSession = session;

      TblUsers user = GetUniqueUserForTesting();
      ServerModel.DB.Insert(user);

      sessionID = session.ID;
      userID = user.ID;
    }
        public async Task <IActionResult> Edit(string id,
                                               [Bind(
                                                    "Id,Name,HsnSacNo,Type,MeasuringUnit,Manufacture,BarCode,ItemUniqueDescription,Supplier,Photo,UseBatchNo,UseMfgDate,UseExpiryDate,CreatedDatetime,Gst")]
                                               TblItems tblItems)
        {
            if (id != tblItems.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblItems);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TblItemsExists(tblItems.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["Gst"]           = new SelectList(_context.TblGst, "Id", "Name", tblItems.Gst);
            ViewData["MeasuringUnit"] = new SelectList(_context.TblItemUnits, "MeasurintUnitId", "MeasuringUnits",
                                                       tblItems.MeasuringUnit);
            ViewData["Supplier"] = new SelectList(_context.TblVendor, "Id", "Name", tblItems.Supplier);
            ViewData["Type"]     = new SelectList(_context.TblItemType, "ItemTypeId", "ItemType", tblItems.Type);
            return(View(tblItems));
        }
Exemple #7
0
        /// <summary>
        /// Store non-leaves
        /// </summary>
        /// <param name="pid">Parent ID of Item</param>
        /// <param name="organizationID">Organization ID to which this item belongs</param>
        /// <param name="title">Title of this item received from "title" tag</param>
        /// <param name="resourceID">Resource to which this item is linked</param>
        /// <param name="item">XmlNode represents *item* tag in answers file with rank tag</param>
        /// <returns>ID of the stored item</returns>
        private static int Store(int?pid, int organizationID, string title, int?resourceID, XmlNode item)
        {
            int?totalRank = null;

            if (item != null)
            {
                XmlNodeList questions = XmlUtility.GetNodes(item, "question");
                totalRank = 0;
                foreach (XmlNode question in questions)
                {
                    int rank = 0;
                    if (int.TryParse(XmlUtility.GetNode(question, "rank").InnerText, out rank))
                    {
                        totalRank += rank;
                    }
                    else
                    {
                        throw new Exception(Translations.ItemManager_Store_Cannot_get_rank_for_item);
                    }
                }
            }

            TblItems t = new TblItems
            {
                PID             = pid,
                OrganizationRef = organizationID,
                Title           = title,
                IsLeaf          = resourceID != null,
                ResourceRef     = resourceID,
                Rank            = totalRank
            };

            ServerModel.DB.Insert(t);

            return(t.ID);
        }
Exemple #8
0
        public void fillStatistic()
        {
            double totalstudntresoult = 0;
            double totalstagerank     = 0;

            user       = ServerModel.DB.Load <TblUsers>(UserId);
            curriculum = ServerModel.DB.Load <TblCurriculums>(CurriculumID);
            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    double           result       = 0; Name_Stage.Add(theme.Name);
                    double           totalresult  = 0;
                    int              learnercount = TeacherHelper.GetLastIndexOfAttempts(user.ID, theme.ID);
                    TblOrganizations organization;
                    organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                    foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                    {
                        totalresult += Convert.ToDouble(items.Rank);
                    }

                    foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                    {
                        if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(user.ID, theme.ID))
                        {
                            foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                            {
                                CmiDataModel cmiDataModel = new CmiDataModel(session.ID, user.ID, false);
                                List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                {
                                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                    {
                                        if (interactionsCollection[j].Name == "result")
                                        {
                                            TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                            if (interactionsCollection[j].Value == "correct")
                                            {
                                                result += Convert.ToDouble(itm.Rank);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    totalstudntresoult += result;
                    totalstagerank     += totalresult;
                    Student_Stage_Count.Add(result);
                    Total_Stage_Count.Add(totalresult);
                }
            }

            Name_Stage.Add("Total");
            Student_Stage_Count.Add(totalstudntresoult);
            Total_Stage_Count.Add(totalstagerank);


            Saveto_Excel_Click();
        }
Exemple #9
0
        private void fillStatisticTable()
        {
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();

            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);


            foreach (TblCurriculums curr in curriculums)
            {
                headerCell = new TableHeaderCell {
                    HorizontalAlign = HorizontalAlign.Center
                };


                headerCell.Controls.Add(new HyperLink
                {
                    Text        = curr.Name,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                    {
                        GroupID      = GroupID,
                        CurriculumID = curr.ID,
                        BackUrl      = RawUrl
                    })
                });
                headerRow.Cells.Add(headerCell);
            }

            headerCell      = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);


            StatisticTable.Rows.Add(headerRow);

            foreach (TblUsers student in TeacherHelper.GetStudentsOfGroup(group))
            {
                var       studentRow  = new TableRow();
                TableCell studentCell = new TableHeaderCell {
                    Text = student.DisplayName
                };

                studentRow.Cells.Add(studentCell);

                double pasedCurriculums = 0;
                double totalCurriculums = 0;
                foreach (TblCurriculums curr in curriculums)
                {
                    double pasedCurriculum = 0;
                    double totalCurriculum = 0;
                    foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curr))
                    {
                        foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                        {
                            double           result           = 0;
                            double           totalresult      = 0;
                            bool             islearnerattempt = false;
                            TblOrganizations organization;
                            organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                            foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                            {
                                totalresult += Convert.ToDouble(items.Rank);
                            }
                            foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                            {
                                if (attempt != null)
                                {
                                    islearnerattempt = true;
                                }
                                if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                                {
                                    foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                    {
                                        CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                        List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                        for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                        {
                                            for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                            {
                                                if (interactionsCollection[j].Name == "result")
                                                {
                                                    TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                                    if (interactionsCollection[j].Value == "correct")
                                                    {
                                                        result += Convert.ToDouble(itm.Rank);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            pasedCurriculum += result;
                            totalCurriculum += totalresult;
                        }
                    }
                    studentCell = new TableCell {
                        HorizontalAlign = HorizontalAlign.Center
                    };

                    studentCell.Controls.Add(new HyperLink
                    {
                        Text        = pasedCurriculum + "/" + totalCurriculum,
                        NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                        {
                            GroupID      = GroupID,
                            CurriculumID = curr.ID,
                            UserId       = student.ID,
                            BackUrl      = RawUrl
                        })
                    });
                    studentRow.Cells.Add(studentCell);

                    pasedCurriculums += pasedCurriculum;
                    totalCurriculums += totalCurriculum;
                }
                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text            = pasedCurriculums + "/" + totalCurriculums
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                double temp_total;
                if (totalCurriculums != 0)
                {
                    temp_total = pasedCurriculums / totalCurriculums * 100;
                }
                else
                {
                    temp_total = 0;
                }
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);
                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
                StatisticTable.HorizontalAlign = HorizontalAlign.Center;
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value          = noStudents;
            }
        }
Exemple #10
0
        private void fillStatisticTable()
        {
            IList <TblUsers> ilistusers;

            ilistusers = TeacherHelper.GetStudentsOfGroup(group);
            if (UserId > 0)
            {
                user = ServerModel.DB.Load <TblUsers>(UserId);
                ilistusers.Clear();
                ilistusers.Add(user);
            }
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();

            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);

            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    headerCell      = new TableHeaderCell();
                    headerCell.Text = theme.Name;
                    headerRow.Cells.Add(headerCell);
                }
            }
            headerCell      = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);

            StatisticTable.Rows.Add(headerRow);
            foreach (TblUsers student in ilistusers)
            {
                var       studentRow  = new TableRow();
                TableCell studentCell = new TableHeaderCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Controls.Add(new HyperLink
                {
                    Text        = student.DisplayName,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowGraphController
                    {
                        GroupID      = GroupID,
                        CurriculumID = curriculum.ID,
                        UserId       = student.ID,
                        BackUrl      = RawUrl
                    })
                });


                studentRow.Cells.Add(studentCell);

                double pasedCurriculum = 0;
                double totalCurriculum = 0;
                foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
                {
                    foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                    {
                        double           result       = 0;
                        double           totalresult  = 0;
                        int              learnercount = TeacherHelper.GetLastIndexOfAttempts(student.ID, theme.ID);
                        TblOrganizations organization;
                        organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                        foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                        {
                            totalresult += Convert.ToDouble(items.Rank);
                        }

                        foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                        {
                            if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                            {
                                foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                {
                                    CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                    List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                    for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                    {
                                        for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                        {
                                            if (interactionsCollection[j].Name == "result")
                                            {
                                                TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                                if (interactionsCollection[j].Value == "correct")
                                                {
                                                    result += Convert.ToDouble(itm.Rank);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }



                        string attmpt = "";
                        if (learnercount > 0)
                        {
                            attmpt = "(" + learnercount.ToString() + " attempt )";
                        }
                        else if (learnercount == 0)
                        {
                            attmpt = "";
                        }

                        studentCell = new TableCell {
                            HorizontalAlign = HorizontalAlign.Center
                        };
                        studentCell.Controls.Add(new HyperLink
                        {
                            Text        = result + "/" + totalresult + attmpt,
                            NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new ThemeResultController
                            {
                                BackUrl          = string.Empty,
                                LearnerAttemptId = TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID),
                            })
                        });

                        if (learnercount == 0)
                        {
                            studentCell.Enabled   = false;
                            studentCell.BackColor = Color.Yellow;
                        }
                        else if (learnercount > 0)
                        {
                            studentCell.BackColor = Color.YellowGreen;
                        }

                        pasedCurriculum += result;
                        totalCurriculum += totalresult;
                        studentRow.Cells.Add(studentCell);
                    }
                }

                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text            = pasedCurriculum + "/" + totalCurriculum
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                double temp_total;
                if (totalCurriculum != 0)
                {
                    temp_total = pasedCurriculum / totalCurriculum * 100;
                }
                else
                {
                    temp_total = 0;
                }
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);

                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value          = noStudents;
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        var currentUser = ServerModel.User.Current;

        if (currentUser != null)
        {
            SetHeaderText(Theme.Name, CurriculumnName, StageName, User.DisplayName);
            //Dictionary<int, TableRow> rows = new Dictionary<int, TableRow>();
            List <TableRow> rows = new List <TableRow>();

            foreach (TblLearnerSessions learnerSession in LearnerSessions)
            {
                //List<TblVarsInteractions> userResults = StatisticManager.GetStatisticForLearnerSession(learnerSession.ID);
                TblItems item = ServerModel.DB.Load <TblItems>(learnerSession.ItemRef);

                string correctAnswer = null;
                string userAnswer    = null;
                string result        = null;

                CmiDataModel cmiDataModel = new CmiDataModel(learnerSession.ID, ServerModel.User.Current.ID, false);
                List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");
                List <TblVarsInteractionCorrectResponses> interactionCorrectResponsesCollection = cmiDataModel.GetCollection <TblVarsInteractionCorrectResponses>("interactions.*.correct_responses.*");
                int count = int.Parse(cmiDataModel.GetValue("interactions._count"));

                for (int i = 0, j = 0; i < count; i++)
                {
                    if (interactionCorrectResponsesCollection[i].Value != null)
                    {
                        correctAnswer = interactionCorrectResponsesCollection[i].Value;
                    }
                    else
                    {
                        continue;
                    }
                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                    {
                        if (interactionsCollection[j].Name == "learner_response")
                        {
                            userAnswer = interactionsCollection[j].Value;
                        }
                        else if (interactionsCollection[j].Name == "result")
                        {
                            result = interactionsCollection[j].Value;
                        }
                    }

                    var row = new TableRow();
                    row.Cells.Add(new TableCell {
                        Text = item.Title
                    });
                    row.Cells.Add(new TableCell {
                        Text = userAnswer
                    });
                    row.Cells.Add(new TableCell {
                        Text = correctAnswer
                    });
                    row.Cells.Add(new TableCell {
                        Text = result
                    });

                    rows.Add(row);
                }

                /*for (int i = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count"));i++)
                 * {
                 * correctAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.correct_responses.0.pattern", i));
                 * userAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.learner_response", i));
                 * result = cmiDataModel.GetValue(String.Format("interactions.{0}.result", i));
                 *
                 * if (correctAnswer == null)
                 * {
                 *  continue;
                 * }
                 *
                 * var row = new TableRow();
                 * row.Cells.Add(new TableCell { Text = item.Title });
                 * row.Cells.Add(new TableCell { Text = userAnswer });
                 * row.Cells.Add(new TableCell { Text = correctAnswer });
                 * row.Cells.Add(new TableCell { Text = result });
                 *
                 * rows.Add(row);
                 * }*/
            }

            foreach (TableRow row in rows)
            {
                _resultTable.Rows.Add(row);
            }
        }
    }
        public async Task <IActionResult> Create(
            [Bind(
                 "Id,Name,HsnSacNo,Type,MeasuringUnit,Manufacture,BarCode,ItemUniqueDescription,Supplier,Photo,UseBatchNo,UseMfgDate,UseExpiryDate,CreatedDatetime,Gst")]
            TblItems items, [Bind("OpeningStock")] int?openingStock)
        {
            if (ModelState.IsValid)
            {
                var saved = false;
                using (var transaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        _context.Add(items);
                        //await _context.SaveChangesAsync();


                        _context.UpdateNextSequence(SequenceTable.tbl_Items);
                        //TblSequence NewSequenceValue = Helper.GenericHelper.GetNextUpdatedData("tbl_Items");
                        //_context.Entry(NewSequenceValue).State = EntityState.Modified;
                        //await _context.SaveChangesAsync();

                        if (openingStock > 0)
                        {
                            TblItemStock tbl_ItemStock = new TblItemStock()
                            {
                                Id              = items.Id + "-" + Helper.GenericHelper.GetMaxValue("tbl_ItemStock") + "-1",
                                StockType       = "IN",
                                InvoiceNo       = "Opening Stock",
                                ItemId          = items.Id,
                                Qty             = openingStock,
                                CreatedDatetime = items.CreatedDatetime.ToString() ??
                                                  DateTime.Now.Date.ToString(CultureInfo.InvariantCulture)
                            };
                            _context.TblItemStock.Add(tbl_ItemStock);
                            //await _context.SaveChangesAsync();
                            _context.UpdateNextSequence(SequenceTable.tbl_ItemStock);
                        }


                        await _context.SaveChangesAsync();

                        saved = true;
                    }
                    catch (Exception e)
                    {
                        throw new InvalidOperationException(e.Message);
                    }
                    finally
                    {
                        if (saved)
                        {
                            transaction.Commit();
                        }
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["Gst"]           = new SelectList(_context.TblGst, "Id", "Name", items.Gst);
            ViewData["MeasuringUnit"] = new SelectList(_context.TblItemUnits, "MeasurintUnitId", "MeasuringUnits",
                                                       items.MeasuringUnit);
            ViewData["Supplier"] = new SelectList(_context.TblVendor, "Id", "Name", items.Supplier);
            ViewData["Type"]     = new SelectList(_context.TblItemType, "ItemTypeId", "ItemType", items.Type);
            return(View(items));
        }
Exemple #13
0
        /// <summary>
        /// Store non-leaves
        /// </summary>
        /// <param name="pid">Parent ID of Item</param>
        /// <param name="organizationID">Organization ID to which this item belongs</param>
        /// <param name="title">Title of this item received from "title" tag</param>
        /// <param name="resourceID">Resource to which this item is linked</param>
        /// <param name="item">XmlNode represents *item* tag in answers file with rank tag</param>
        /// <returns>ID of the stored item</returns>
        private static int Store(int? pid, int organizationID, string title, int? resourceID, XmlNode item)
        {
            int? totalRank = null;
            if(item!=null)
            {
                XmlNodeList questions = XmlUtility.GetNodes(item, "question");
                totalRank = 0;
                foreach (XmlNode question in questions)
                {
                  int rank = 0;
                  if (int.TryParse(XmlUtility.GetNode(question, "rank").InnerText, out rank))
                  {
                    totalRank += rank;
                  }
                  else
                  {
                    throw new Exception(Translations.ItemManager_Store_Cannot_get_rank_for_item);
                  }
                }
            }

            TblItems t = new TblItems
            {
                PID = pid,
                OrganizationRef = organizationID,
                Title = title,
                IsLeaf = resourceID != null,
                ResourceRef = resourceID,
                Rank = totalRank
            };

            ServerModel.DB.Insert(t);

            return t.ID;
        }