public List<FormListItemDisplay> BulkUpdate(BulkUpdateModel model)
 {
     if (model.Ids == null || !model.Ids.Any())
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No form selected."));
     }
     var resultItems = _formService.BulkUpdate(model)
         .Select(Mapper.Map<IContent, ContentItemBasic<ContentPropertyBasic, IContent>>)
         .Select(Mapper.Map<ContentItemBasic<ContentPropertyBasic, IContent>, FormListItemDisplay>).ToList();
     return resultItems;
 }
示例#2
0
        public IEnumerable<IContent> BulkUpdate(BulkUpdateModel model)
        {
            var contentService = ApplicationContext.Current.Services.ContentService;
            var forms = contentService.GetByIds(model.Ids).ToList();

            switch (model.BulkType)
            {
                case "update":
                    forms.ForEach(x => FormBulkUpdate(x, model));
                    break;
                case "add":
                    forms.ForEach(x => FormBulkAdd(x, model));
                    break;
                case "remove":
                    forms.ForEach(x => FormBulkRemove(x, model));
                    break;
                case "archive":
                    forms.ForEach(x => FormBulkArchive(x));
                    break;
            }
            contentService.Save(forms.Where(x => x.IsDirty()));

            return forms;
        }
示例#3
0
 private IContent FormBulkUpdate(IContent form, BulkUpdateModel model)
 {
     if (model.Tags != null)
     {
         form.SetTags("formTags", model.Tags, true, TAG_GROUP_GLEANER_FORM);
     }
     if (model.Groups != null)
     {
         form.SetValue("associatedGroups", string.Join(",", model.Groups));
     }
     if (model.IsPublic.HasValue)
     {
         form.SetValue("isPublic", model.IsPublic.Value);
     }
     if (model.IsRequired.HasValue)
     {
         form.SetValue("isRequired", model.IsRequired.Value);
     }
     if (model.StartDate.HasValue)
     {
         form.SetValue("startDate", model.StartDate.Value);
     }
     if (model.EndDate.HasValue)
     {
         form.SetValue("endDate", model.EndDate.Value);
     }
     return form;
 }
示例#4
0
 private IContent FormBulkRemove(IContent form, BulkUpdateModel model)
 {
     if (model.Tags != null)
     {
         form.RemoveTags("formTags", model.Tags, TAG_GROUP_GLEANER_FORM);
     }
     if (model.Groups != null)
     {
         var currentValue = form.GetValue<string>("associatedGroups").ToDelimitedList().Select(Int32.Parse);
         form.SetValue("associatedGroups", string.Join(",", currentValue.Except(model.Groups)));
     }
     return form;
 }