public async Task <IActionResult> AddService(int?id) { if (id == null) { return(NotFound()); } var activity = await _dataContext.Activities .Include(p => p.Referee) .FirstOrDefaultAsync(p => p.Id == id.Value); if (activity == null) { return(NotFound()); } var model = new ServiceViewModel { RefereeId = activity.Referee.Id, ActivityId = activity.Id, Clients = _combosHelper.GetComboClients(), Price = activity.Price, StartDate = DateTime.Today, }; model.Clients = _combosHelper.GetComboClients(); return(View(model)); }
public ServiceViewModel ToServiceViewModel(Service service) { return(new ServiceViewModel { Id = service.Id, IsActive = service.IsActive, Client = service.Client, Referee = service.Referee, Price = service.Price, Activity = service.Activity, Remarks = service.Remarks, StartDate = service.StartDateLocal, ClientId = service.Client.Id, Clients = _combosHelper.GetComboClients(), RefereeId = service.Referee.Id, ActivityId = service.Activity.Id }); }