public JsonResult Update(SectionModal section)
        {
            section.SemesterId = GetSemesterId(Int32.Parse(section.SemesterNo));


            return(Json(_databaseConnection.Update(section), JsonRequestBehavior.AllowGet));
        }
Example #2
0
 public void Put(int sectionId, [FromBody] Section prod)
 {
     prod.SectionId = sectionId;
     if (ModelState.IsValid)
     {
         sectionRepository.Update(prod);
     }
 }
Example #3
0
        public async Task UpdateSection_SetsNameInDb()
        {
            // Arrange
            var lCreatedEntity = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = EntitiesHelper.GetSectionType()
            });

            var lNewSalonYear = EntitiesHelper.GetSalonYear();

            lNewSalonYear.Name       = "new salon year";
            lCreatedEntity.SalonYear = lNewSalonYear;

            // Act
            await sectionRepository.Update(lCreatedEntity);

            // Assert
            var lResult = await sectionRepository.GetById(lCreatedEntity.Id);

            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("new salon year", lResult.SalonYear.Name);
        }
Example #4
0
        /// <summary>
        /// change the section parent
        /// </summary>
        /// <param name="sectionId">identifier of section</param>
        /// <param name="parentId">identifier of parent section</param>
        /// <returns>returns the result to action</returns>
        public JsonResult ChangeParent(int sectionId, int parentId)
        {
            SectionRepository objsection = new SectionRepository(SessionCustom);
            SectionManagement objman     = new SectionManagement(SessionCustom, HttpContext);

            objsection.Entity.SectionId = sectionId;
            objsection.LoadByKey();

            if (parentId != 0)
            {
                objsection.Entity.ParentId = parentId;
            }
            else
            {
                objsection.Entity.ParentId = null;
            }

            objsection.Update();
            objsection.Entity = new Section();

            objman.CreateTreeView(sectionId, objsection.GetAll());

            return(this.Json(new { result = true, html = objman.Tree }));
        }
Example #5
0
        public static Section cloneSectionFromTemplate(SectionTemplate t, Document d)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                IAuditReader reader = AuditReaderFactory.Get(session);
                var revision = reader.CreateQuery()
                                .ForRevisionsOfEntity(typeof(SectionTemplate), false, true)
                                .AddProjection(AuditEntity.RevisionNumber().Max())
                                .Add(AuditEntity.Id().Eq(t.id))
                                .GetSingleResult();

                Section s = new Section();
                s.template = t;
                s.templateRevisionId = (int)revision;
                s.documentIndex = t.documentIndex;
                s.headline = t.headline;
                s.htmlContent = t.htmlContent;
                s.document = d;

                SectionRepository repo = new SectionRepository();

                repo.Create(s);

                foreach (DataFieldTemplate item in t.dataFields)
                {
                    DataField df = cloneDataFieldFromTemplate(item, s);

                    string toReplace = "{dataField=" + item.id + "}";
                    string replaceWith = "{dataField=" + df.id + "}";

                    s.htmlContent = s.htmlContent.Replace(toReplace, replaceWith);
                }

                repo.Update(s);

                return s;
            }
        }
Example #6
0
        /// <summary>
        /// inserts or updates a section object
        /// </summary>
        /// <param name="objSection">object section</param>
        /// <returns>returns true if operation successful</returns>
        public bool SaveSection(Section objSection)
        {
            try
            {
                SectionRepository sectionRepository = new SectionRepository(this.session);

                string section = objSection.Name;

                sectionRepository.Entity = objSection;
                if (sectionRepository.Entity.SectionId != null)
                {
                    if (null != objSection.OldOrder && objSection.Sectionorder != null && objSection.Sectionorder != objSection.OldOrder)
                    {
                        sectionRepository.ChangeOrder(sectionRepository.Entity.Sectionorder.Value, objSection.OldOrder.Value);
                    }

                    sectionRepository.Update();

                    FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                    friendlyrepo.Entity.Id            = sectionRepository.Entity.SectionId;
                    friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname;
                    friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Section;
                    friendlyrepo.Update();

                    InfoCache <List <Section> > cache = new InfoCache <List <Section> >(this.context)
                    {
                        TimeOut = 120
                    };
                    sectionRepository.Entity = new Section();
                    cache.SetCache("sections", sectionRepository.GetAll());

                    Utils.InsertAudit(
                        this.session,
                        new Audit()
                    {
                        Auditaction = "Update",
                        Description = "Section -> " + section,
                        Joindate    = DateTime.Now,
                        Username    = (this.context.User as CustomPrincipal).UserId
                    });
                }
                else
                {
                    sectionRepository.Entity.Sectionorder = sectionRepository.GetMaxOrder();
                    sectionRepository.Entity.Friendlyname = Utils.GetFindFrienlyName(
                        this.session,
                        sectionRepository.Entity.Name,
                        sectionRepository.Entity.Sectionorder.Value);
                    sectionRepository.Entity.SectionId = Convert.ToInt32(sectionRepository.Insert());

                    FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                    friendlyrepo.Entity.Id            = sectionRepository.Entity.SectionId;
                    friendlyrepo.Entity.Friendlyurlid = sectionRepository.Entity.Friendlyname;
                    friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Section;
                    friendlyrepo.Entity.LanguageId    = sectionRepository.Entity.LanguageId;
                    friendlyrepo.Insert();

                    Utils.InsertAudit(
                        this.session,
                        new Audit()
                    {
                        Auditaction = "Insert",
                        Description = "Section -> " + section,
                        Joindate    = DateTime.Now,
                        Username    = (this.context.User as CustomPrincipal).UserId
                    });
                }

                return(true);
            }
            catch (Exception ex)
            {
                Utils.InsertLog(
                    this.session,
                    "Insert Section",
                    ex.Message + " - " + ex.StackTrace);
                return(false);
            }
        }