public Member Map(CreateOrEditViewModel createOrEdit)
        {
            Member member = new Member();

            if (createOrEdit.Id != null)
            {
                member = this.handler.Storage.GetRepository <IMemberRepository>().WithKey((int)createOrEdit.Id);
            }

            else
            {
                member.ClassId = createOrEdit.ClassId;
            }

            member.TabId                   = createOrEdit.TabId;
            member.Code                    = createOrEdit.Code;
            member.Name                    = createOrEdit.Name;
            member.Position                = createOrEdit.Position;
            member.PropertyDataTypeId      = createOrEdit.PropertyDataTypeId;
            member.IsPropertyLocalizable   = createOrEdit.IsPropertyLocalizable ? true : (bool?)null;
            member.IsPropertyVisibleInList = createOrEdit.IsPropertyVisibleInList ? true : (bool?)null;
            member.RelationClassId         = createOrEdit.RelationClassId;
            member.IsRelationSingleParent  = createOrEdit.IsRelationSingleParent ? true : (bool?)null;
            return(member);
        }
Exemplo n.º 2
0
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            Member member = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IMemberRepository>().Create(member);

            else this.Storage.GetRepository<IMemberRepository>().Edit(member);

            this.Storage.Save();
            return this.Redirect(this.Request.CombineUrl("/backend/members"));
              }

              return this.CreateRedirectToSelfResult();
        }
        public Member Map(CreateOrEditViewModel createOrEdit)
        {
            Member member = new Member();

              if (createOrEdit.Id != null)
            member = this.handler.Storage.GetRepository<IMemberRepository>().WithKey((int)createOrEdit.Id);

              else member.ClassId = createOrEdit.ClassId;

              member.TabId = createOrEdit.TabId;
              member.Code = createOrEdit.Code;
              member.Name = createOrEdit.Name;
              member.DisplayInList = createOrEdit.DisplayInList ? true : (bool?)null;
              member.Position = createOrEdit.Position;
              member.RelationClassId = createOrEdit.RelationClassId;
              member.IsRelationSingleParent = createOrEdit.IsRelationSingleParent ? true : (bool?)null;
              member.PropertyDataTypeId = createOrEdit.PropertyDataTypeId;
              return member;
        }