public static TimeLogUnit Map(TimeLogUnitViewModel viewModel, TimeLogUnit entity) { if (viewModel == null || entity == null) { return(null); } entity.Id = viewModel.UnitId; entity.Name = viewModel.UnitName; entity.SortOrder = viewModel.SortOrder; entity.IsActive = viewModel.IsActive; return(entity); }
public async Task <TimeLogUnitViewModel> Create(TimeLogUnitViewModel model) { var timelogUnit = this.TimeLogUnitRepository.Add(ViewModelToEntityMapper.Map(model)); if (timelogUnit.Id > 0) { model.UnitId = timelogUnit.Id; } else { model.HasError = true; } return(model); }
public static TimeLogUnit Map(TimeLogUnitViewModel viewModel) { if (viewModel == null) { return(null); } return(new TimeLogUnit { Id = viewModel.UnitId, Name = viewModel.UnitName, SortOrder = viewModel.SortOrder, IsActive = viewModel.IsActive }); }
public async Task <TimeLogUnitViewModel> Update(TimeLogUnitViewModel model) { var timelogUnit = this.TimeLogUnitRepository.Find(model.UnitId); if (timelogUnit != null) { var lastModifiedDate = timelogUnit.LastModifiedDate; timelogUnit = this.TimeLogUnitRepository.Update(ViewModelToEntityMapper.Map(model, timelogUnit)); if (lastModifiedDate < timelogUnit.LastModifiedDate) { return(model); } else { model.HasError = true; } } return(model); }