public async Task <IActionResult> PutProductCategorie([FromRoute] Guid Id, [FromBody] HospitalCategory obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != obj.Id) { return(BadRequest()); } _context.Entry(obj).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//TODO abastrat : shitty code alert (for demo) protected override void OnCommitted() { if (string.IsNullOrEmpty(NewCategoryViewModel.Name)) { return; } try { var cat = new HospitalCategory(HospitalDataService.LazyHospitalRegistry.Value) { Name = NewCategoryViewModel.Name }; var vm = new HospitalCategoryViewModel(cat); HospitalDataService.HospitalCategoryViewModels.Add(vm); EventAggregator.GetEvent <HospitalCategoryCollectionChangedEvent>().Publish(true); HospitalDataService.HospitalCategoryViewModels.Move(HospitalCategoryViewModels.Count - 1, 0); SelectedCategory = vm; EventAggregator.GetEvent <GenericNotificationEvent>().Publish(string.Format("Category {0} has updated", vm.Name)); NewCategoryViewModel = new HospitalCategoryViewModel(new HospitalCategory(null)); } catch (Exception ex) { //TODO FIX BUGS IN THE INFASTRUCTURE //EventAggregator.GetEvent<ErrorNotificationEvent>().Publish(ex); } _reset(); }
public async Task <IActionResult> PostProductCategorie([FromBody] HospitalCategory obj) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.HospitalCategories.Add(obj); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOperationCategories", new { Id = obj.Id }, obj)); }
public void Delete(HospitalCategory HospitalCategory) { using (var sess = Provider.SessionFactory.OpenSession()) { var tx = sess.BeginTransaction(); try { var catdelete = string.Format("delete from {0} entity where entity.Id = {1}" , typeof(HospitalCategory).FullName, HospitalCategory.Id); sess.CreateQuery(catdelete) .SetTimeout((int)ConfigurationService.MonahrqSettings.ShortTimeout.TotalSeconds) .ExecuteUpdate(); tx.Commit(); } catch { tx.Rollback(); throw; } } }