protected override void OnSaveToolBarItem() { ReadData(_activeUom); using (var dbContext = new FarnahadManufacturingDbContext()) { bool isSaved = true; if (_activeUom.Id > 0) { var activeUomInDb = dbContext.Uoms.First(item => item.Id == _activeUom.Id); if (activeUomInDb.ReadOnly) { MessageBoxService.CannotEditPrompt(_activeUom.Title); isSaved = false; } else { activeUomInDb.Title = _activeUom.Title; activeUomInDb.Abbreviation = _activeUom.Abbreviation; activeUomInDb.ReadOnly = _activeUom.ReadOnly; activeUomInDb.Conversion = _activeUom.Conversion; activeUomInDb.Description = _activeUom.Description; activeUomInDb.IsActive = _activeUom.IsActive; activeUomInDb.UomType = _activeUom.UomType; dbContext.SaveChanges(); IsEditing(); } } else { _activeUom.CreatedByUserId = ApplicationSessionService.GetActiveUserId(); _activeUom.CreatedDateTime = ApplicationSessionService.GetNowDateTime(); dbContext.Uoms.Add(_activeUom); dbContext.SaveChanges(); OnAddToolBarItem(); } if (isSaved) { MessageBoxService.SaveConfirmation(_activeUom.Title); LoadSearchGridControl(); } } }