public PartialViewResult EditAttachmentType(AttachmentTypePrimaryKey attachmentTypePrimaryKey) { var attachmentType = attachmentTypePrimaryKey.EntityObject; var viewModel = new EditAttachmentTypeViewModel(attachmentType); return(ViewEditAttachmentType(viewModel)); }
public PartialViewResult DeleteAttachmentType(AttachmentTypePrimaryKey attachmentTypePrimaryKey) { var attachmentType = attachmentTypePrimaryKey.EntityObject; var viewModel = new ConfirmDialogFormViewModel(attachmentType.AttachmentTypeID); return(ViewDeleteAttachmentType(attachmentType, viewModel)); }
public PartialViewResult FieldDefinitionDetailsForAttachmentType(AttachmentTypePrimaryKey attachmentTypePrimaryKey) { var attachmentType = attachmentTypePrimaryKey.EntityObject; var viewData = new FieldDefinitionDetailsViewData(attachmentType, false, string.Empty, new HtmlString( $"{attachmentType.AttachmentTypeDescription}{(attachmentType.NumberOfAllowedAttachments.HasValue ? $"<p class=\"smallExplanationText\"><strong>Maximum File Uploads:</strong> <span>{attachmentType.NumberOfAllowedAttachments} </span></p>" : string.Empty)}"), attachmentType.AttachmentTypeName); return(RazorPartialView <FieldDefinitionDetails, FieldDefinitionDetailsViewData>(viewData)); }
public ActionResult DeleteAttachmentType(AttachmentTypePrimaryKey attachmentTypePrimaryKey, ConfirmDialogFormViewModel viewModel) { var attachmentType = attachmentTypePrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewDeleteAttachmentType(attachmentType, viewModel)); } attachmentType.DeleteFull(HttpRequestStorage.DatabaseEntities); return(new ModalDialogFormJsonResult()); }
public virtual IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { CheckForNotNullProjectId(); var validationResults = new List <ValidationResult>(); FileResourceModelExtensions.ValidateFileSize(UploadedFile, validationResults, "File"); // Attachments must have unique display names at the project and attachment type level if (HttpRequestStorage.DatabaseEntities.ProjectAttachments.Any(x => x.ProjectID == ProjectID && x.DisplayName == DisplayName && x.AttachmentTypeID == AttachmentTypeID)) { AttachmentTypePrimaryKey attachmentTypePrimaryKey = AttachmentTypeID; var attachmentType = attachmentTypePrimaryKey.EntityObject; validationResults.Add(new SitkaValidationResult <NewProjectAttachmentViewModel, string>($"There is already an attachment with the display name \"{DisplayName}\" under the {attachmentType.AttachmentTypeName} attachment type for this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}.", m => m.DisplayName)); } return(validationResults); }
public ActionResult EditAttachmentType(AttachmentTypePrimaryKey attachmentTypePrimaryKey, EditAttachmentTypeViewModel viewModel) { var attachmentType = attachmentTypePrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditAttachmentType(viewModel)); } HttpRequestStorage.DatabaseEntities.AttachmentTypeFileResourceMimeTypes.Load(); var attachmentTypeFileResourceMimeTypes = HttpRequestStorage.DatabaseEntities.AllAttachmentTypeFileResourceMimeTypes.Local; HttpRequestStorage.DatabaseEntities.AttachmentTypeTaxonomyTrunks.Load(); var attachmentTypeTaxonomyTrunks = HttpRequestStorage.DatabaseEntities.AllAttachmentTypeTaxonomyTrunks.Local; viewModel.UpdateModel(attachmentType, attachmentTypeFileResourceMimeTypes, attachmentTypeTaxonomyTrunks); return(new ModalDialogFormJsonResult()); }
public virtual IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validationResults = new List <ValidationResult>(); ProjectAttachmentPrimaryKey projectAttachmentPrimaryKey = AttachmentID; var projectAttachment = projectAttachmentPrimaryKey.EntityObject; // We want to validate that the DisplayName is unique per project & attachment type. A project can have duplicate display names as long as they are different attachment types if (HttpRequestStorage.DatabaseEntities.ProjectAttachments.Where(x => x.ProjectID == ParentID && x.ProjectAttachmentID != AttachmentID && x.AttachmentTypeID == projectAttachment.AttachmentTypeID) .Any(x => x.DisplayName.ToLower() == DisplayName.ToLower())) { AttachmentTypePrimaryKey attachmentTypePrimaryKey = projectAttachment.AttachmentTypeID; var attachmentType = attachmentTypePrimaryKey.EntityObject; validationResults.Add(new SitkaValidationResult <NewProjectAttachmentViewModel, string>($"There is already an attachment with the display name \"{DisplayName}\" under the {attachmentType.AttachmentTypeName} attachment type for this {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}.", m => m.DisplayName)); } return(validationResults); }