public IActionResult AddOrEdit(int?id) { AddOrEdit addOrEdit = new AddOrEdit(); if (id == null) { addOrEdit.NameLocalizations = this.CreateEmptyLocalizations(); } else { Data.Entities.Library library = this.libraryRepository.GetById((int)id); addOrEdit.NameLocalizations = this.CreateLocalizationsFor(library.Name); } return(this.View(addOrEdit)); }
public IActionResult AddOrEdit(AddOrEdit addOrEdit) { if (!this.ModelState.IsValid) { return(this.RedirectToAction("AddOrEdit")); } Data.Entities.Library library = addOrEdit.Id == null ? new Data.Entities.Library() : this.libraryRepository.GetById((int)addOrEdit.Id); this.CreateOrUpdateLocalizationsFor(library); if (addOrEdit.Id == null) { this.libraryRepository.Create(library); } else { this.libraryRepository.Update(library); } this.storage.SaveChanges(); return(this.RedirectToAction("Index")); }
public void Put(int id, [FromBody] Data.Entities.Library library) { }
public async Task Post([FromBody] Data.Entities.Library library) { await db.Library.AddAsync(library); }