async Task Save() { if (String.IsNullOrWhiteSpace(Module.moduleID) && String.IsNullOrWhiteSpace(Module.creditID) && String.IsNullOrWhiteSpace(Module.staffID) && String.IsNullOrWhiteSpace(Module.moduleName) && String.IsNullOrWhiteSpace(Module.courseID)) { await _pageService.DisplayAlert("Error", "Please enter All the Fields", "OK"); return; } if (Module.id == 0) { await _moduleStore.AddModule(Module); ModuleAdded?.Invoke(this, Module); } else { await _moduleStore.UpdateModule(Module); ModuleUpdated?.Invoke(this, Module); } await _pageService.PopModalAsync(); }
public ActionResult <Module> AddModule([FromBody] Module value) { Task <Module> data = module.AddModule(value); if (data.IsCanceled) { return(BadRequest(data.Exception)); } else if (data.Result == null) { return(NoContent()); } else { return(Ok(data.Result)); } }
public async Task <Module> AddModule(Guid id, CreateModuleViewModel module) { byte[] imageData = null; using (var binaryReader = new BinaryReader(module.Image.OpenReadStream())) { imageData = binaryReader.ReadBytes((int)module.Image.Length); } Course course = await _courseService.GetCourse(id); Module new_module = new Module { Id = Guid.NewGuid(), Name = module.Name, Description = module.Description, Image = imageData, Modified = DateTime.Now, CourseId = course.Id, }; await _module.AddModule(new_module); return(new_module); }