Esempio n. 1
0
        public DataField AddNewToSection(int sectionId, string fieldDescription)
        {
            Section section = new SectionRepository().GetById(sectionId);
            if (section == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            DataField newDataField = new DataField();

            newDataField.section = section;

            if (fieldDescription!=null)
            {
                newDataField.description = fieldDescription;
            }

            if (section.dataFields.Any(x => x.description==newDataField.description))
            {
                HttpResponseMessage mss = new HttpResponseMessage();
                mss.StatusCode = HttpStatusCode.BadRequest;
                mss.ReasonPhrase = "Duplicate field description";
                throw new HttpResponseException(mss);
            }

            repo.Create(newDataField);

            return newDataField;
        }
Esempio n. 2
0
        public static DataField cloneDataFieldFromTemplate(DataFieldTemplate t, Section s)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                IAuditReader reader = AuditReaderFactory.Get(session);
                var revision = reader.CreateQuery()
                                .ForRevisionsOfEntity(typeof(DataFieldTemplate), false, true)
                                .AddProjection(AuditEntity.RevisionNumber().Max())
                                .Add(AuditEntity.Id().Eq(t.id))
                                .GetSingleResult();

                DataField d = new DataField();
                d.template = t;
                d.templateRevisionId = (int)revision;
                d.description = t.description;
                d.section = s;

                new DataFieldRepository().Create(d);

                return d;
            }
        }
Esempio n. 3
0
 public ActionResult RedigerNytDatafelt(Bizdoc.Web.ViewModels.NewDataField model)
 {
     DataField datafield = new DataField { description = model.description, section = new Section { id = model.sectionId } };
     return PartialView(datafield);
 }
Esempio n. 4
0
        public virtual bool Equals(DataField d)
        {
            // If parameter is null return false.
            if (d == null)
            {
                return false;
            }

            //Check id
            if (!(d.id == null && id == null))
            {
                if (d.id == null || id == null)
                {
                    return false;
                }

                if (d.id != id)
                {
                    return false;
                }
            }

            //Check description
            if (!(d.description == null && description == null))
            {
                if (d.description == null || description == null)
                {
                    return false;
                }

                if (!d.description.Equals(description))
                {
                    return false;
                }
            }

            //Check value
            if (!(d.value == null && value == null))
            {
                if (d.value == null || value == null)
                {
                    return false;
                }

                if (!d.value.Equals(value))
                {
                    return false;
                }
            }

            //Check variables
            if (d.templateRevisionId!=templateRevisionId)
            {
                return false;
            }

            //Check object members - document
            if (!(d.section == null && section == null))
            {
                if (d.section == null || section == null)
                {
                    return false;
                }

                if (d.section.id != section.id)
                {
                    return false;
                }
            }

            //Check object members - document
            if (!(d.template == null && template == null))
            {
                if (d.template == null || template == null)
                {
                    return false;
                }

                if (d.template.id != template.id)
                {
                    return false;
                }
            }

            return true;
        }