public async Task <ResponseModel> Item(int id) { ResponseModel response = new ResponseModel(); try { SpecializedTraining md = await _context.SpecializedTrainingRepository.FirstOrDefaultAsync(m => m.Id == id); if (md == null) { throw new NullParameterException(); } SpecializedTrainingModel model = new SpecializedTrainingModel() { Id = md.Id, Name = md.Name, Description = md.Description, IsActive = md.IsActive, RowVersion = md.RowVersion, }; response.Result = model; } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Delete(SpecializedTrainingModel model) { ResponseModel response = new ResponseModel(); try { SpecializedTraining md = await _context.SpecializedTrainingRepository.FirstOrDefaultAsync(m => m.Id == model.Id); if (!md.RowVersion.SequenceEqual(model.RowVersion)) { response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.OutOfDateData; return(response); } md.Deleted = true; md.UpdateBy = base.UserId; md.UpdateDate = DateTime.Now; _context.SpecializedTrainingRepository.Update(md); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Insert(SpecializedTrainingModel model) { ResponseModel response = new ResponseModel(); try { SpecializedTraining md = new SpecializedTraining(); md.Name = model.Name; md.Description = model.Description; md.IsActive = model.IsActive; md.CreateBy = base.UserId; md.CreateDate = DateTime.Now; await _context.SpecializedTrainingRepository.AddAsync(md).ConfigureAwait(true); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Delete([FromBody] SpecializedTrainingModel model) { var response = await _specializedTrainingService.Delete(model); return(response); }