示例#1
0
        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));
        }
示例#2
0
        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"));
        }
示例#3
0
 public void Put(int id, [FromBody] Data.Entities.Library library)
 {
 }
示例#4
0
 public async Task Post([FromBody] Data.Entities.Library library)
 {
     await db.Library.AddAsync(library);
 }