public async Task <ResponseModel> Item(int id) { ResponseModel response = new ResponseModel(); try { TrainingType md = await _context.TrainingTypeRepository.FirstOrDefaultAsync(m => m.Id == id); TrainingTypeModel model = new TrainingTypeModel() { Id = md.Id, Name = md.Name, Description = md.Description, Precedence = md.Precedence, IsActive = md.IsActive, RowVersion = md.RowVersion, }; response.Result = model; } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Delete(TrainingTypeModel model) { ResponseModel response = new ResponseModel(); try { TrainingType md = await _context.TrainingTypeRepository.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.TrainingTypeRepository.Update(md); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Insert(TrainingTypeModel model) { ResponseModel response = new ResponseModel(); try { TrainingType md = new TrainingType(); md.Name = model.Name; md.Description = model.Description; md.Precedence = model.Precedence; md.IsActive = model.IsActive; md.CreateBy = base.UserId; md.CreateDate = DateTime.Now; await _context.TrainingTypeRepository.AddAsync(md).ConfigureAwait(true); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
private static TrainingTypeModel PrepareTrainingTypeModel(TrainingType trainingType) { TrainingTypeModel trainingTypeTemp = new TrainingTypeModel(); trainingTypeTemp.Id = trainingType.Id; trainingTypeTemp.Name = trainingType.Name; if (trainingType.IsActive != null) { trainingTypeTemp.IsActive = trainingType.IsActive.Value; } return(trainingTypeTemp); }
public async Task <ResponseModel> Delete([FromBody] TrainingTypeModel model) { var response = await _trainingTypeService.Delete(model); return(response); }
protected TrainingViewModel(TrainingTypeModel type) { Type = type; }