Beispiel #1
0
        public void Edit(Guid id, ServiceFormHolder formHolder)
        {
            var service = serviceRepository.Find(id);
            var formId  = service.FormId;

            service.Name            = formHolder.ServiceForm.Name;
            service.Description     = formHolder.ServiceForm.Description;
            service.Icon            = formHolder.ServiceForm.Icon;
            service.Url             = formHolder.ServiceForm.Url;
            service.Type            = formHolder.ServiceForm.Type;
            service.Method          = formHolder.ServiceForm.Method;
            service.UniqueScriptUrl = formHolder.ServiceForm.UniqueScriptUrl;
            service.SortIndex       = formHolder.ServiceForm.SortIndex;
            service.Code            = formHolder.ServiceForm.Code;

            if (formHolder.HasForm)
            {
                if (formId == null)
                {
                    CreateForm(formHolder.FormModel, service);
                }
                else
                {
                    EditForm(formId, formHolder.FormModel);
                }
            }
            else
            {
                if (formId != null)
                {
                    DeleteFormField(formId ?? Guid.Empty);
                    var form = formRepository.Find(formId);
                    entityRepository.DeleteOnSave(form);
                }
            }

            entityRepository.SaveChanges();
        }
Beispiel #2
0
        public void Create(ServiceFormHolder formHolder)
        {
            var service = serviceFactory.Create
                          (
                formHolder.ServiceForm.Name,
                formHolder.ServiceForm.Description,
                formHolder.ServiceForm.Icon,
                formHolder.ServiceForm.Url,
                formHolder.ServiceForm.Type,
                formHolder.ServiceForm.Method,
                formHolder.ServiceForm.UniqueScriptUrl,
                formHolder.ServiceForm.SortIndex,
                formHolder.ServiceForm.Code,
                null
                          );

            if (formHolder.HasForm)
            {
                CreateForm(formHolder.FormModel, service);
            }

            entityRepository.InsertOnSave(service);
            entityRepository.SaveChanges();
        }