public static Result <bool> IsInstructor(ModuleDraft module, ObjectId userId) { if (module.InstructorId.HasValue || module.ExtraInstructorIds.Any()) { if (module.InstructorId.Value == userId) { return(Result.Ok(true)); } else if (module.ExtraInstructorIds.Any(x => x == userId)) { return(Result.Ok(true)); } } return(Result.Ok(false)); }
public static Result <ModuleDraft> Create( ObjectId moduleId, string title, string excerpt, string imageUrl, bool published, ObjectId?instructorId, string instructor, string instructorMiniBio, string instructorImageUrl, Duration duration, Duration videoDuration = null, string videoUrl = "", string certificateUrl = "", string storeUrl = "", string ecommerceUrl = "", bool createInEcommerce = false, List <Tag> tags = null, List <ObjectId> tutorsIds = null, List <ObjectId> extraInstructorIds = null, ModuleGradeTypeEnum moduleGradeType = ModuleGradeTypeEnum.SubjectsLevel ) { var module = new ModuleDraft() { Id = ObjectId.GenerateNewId(), ModuleId = moduleId, Title = title, Excerpt = excerpt, InstructorId = instructorId.HasValue ? instructorId : ObjectId.Empty, Instructor = instructor, InstructorMiniBio = instructorMiniBio, ExtraInstructorIds = extraInstructorIds, ImageUrl = imageUrl, InstructorImageUrl = instructorImageUrl, Published = published, Duration = duration, Tags = tags, CertificateUrl = certificateUrl, TutorsIds = tutorsIds, StoreUrl = storeUrl, EcommerceUrl = ecommerceUrl, VideoDuration = videoDuration, VideoUrl = videoUrl, CreateInEcommerce = createInEcommerce, DraftPublished = false, ModuleGradeType = moduleGradeType }; return(Result.Ok(module)); }