public async Task <IActionResult> Edit(LottCollector collector) { if (ModelState.IsValid) { try { var company = await _companyRepository.GetCompany(1); // TODO: Pending to change to: this.User.Identity.Name collector.User = await _userHelper.GetUserByEmailAsync("*****@*****.**"); collector.IdType = company.IdType; collector.FechaHora = DateTime.UtcNow; await _collectorRepository.UpdateAsync(collector); } catch (DbUpdateConcurrencyException) { if (!await _collectorRepository.ExistAsync(collector.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(collector)); }
private CollectorViewModel ToCollectorViewModel(LottCollector collector) { return(new CollectorViewModel { IdType = collector.IdType, FirstName = collector.FirstName, LastName = collector.LastName, FixedPhone = collector.FixedPhone, CellPhone = collector.CellPhone, Address = collector.Address, User = collector.User, FechaHora = collector.FechaHora, Status = collector.Status }); }
public async Task <IActionResult> Create(LottCollector collector) { if (ModelState.IsValid) { var company = await _companyRepository.GetCompany(1); // TODO: Pending to change to: this.User.Identity.Name collector.User = await _userHelper.GetUserByEmailAsync("*****@*****.**"); collector.IdType = company.IdType; collector.FechaHora = DateTime.UtcNow; await _collectorRepository.CreateAsync(collector); return(RedirectToAction(nameof(Index))); } return(View(collector)); }