public async Task <SaleViewModel> GetSale(int id) { var sale = await _context.Sales .Include(u => u.User) .Include(c => c.Client) .FirstOrDefaultAsync(v => v.IdSale == id); if (sale == null) { return(null); } return(new SaleViewModel { IdSale = sale.IdSale, IdUser = sale.IdUser, UserName = sale.User.UserName, IdClient = sale.IdClient, ClientName = sale.Client.Name + " " + sale.Client.LastName, TypeSale = sale.TypeSale, VoucherSeries = sale.VoucherSeries, VoucherNumber = sale.VoucherNumber, SaleDate = _context.Entry(sale).Property <DateTime>("DateOn").CurrentValue.Date, SaleDateUpdate = _context.Entry(sale).Property <DateTime>("LastUpdated").CurrentValue.Date, TotalPrice = sale.TotalPrice, State = sale.State }); }
public async Task <UserViewModel> GetUser(int id) { var user = await _context.Users.FindAsync(id); if (user == null) { return(null); } return(new UserViewModel { IdUser = user.IdUser, IdRole = user.IdRole, UserName = user.UserName, DocumentType = user.DocumentType, DocumentNumber = user.DocumentNumber, Address = user.Address, PhoneNumber = user.PhoneNumber, CreatedDate = _context.Entry(user).Property <DateTime>("DateOn").CurrentValue, Email = user.Email, PasswordHash = user.PasswordHash, PasswordSalt = user.PasswordSalt, Condition = user.Condition, }); }
public async Task <LossesViewModel> GetLoss(int id) { var loss = await _context.Losses.FindAsync(id); if (loss == null) { return(null); } return(new LossesViewModel { IdLosses = loss.IdLosses, DateLoss = _context.Entry(loss).Property <DateTime>("DateOn").CurrentValue, Cause = loss.Cause, State = loss.State }); }
public async Task <DeliveryViewModel> GetDelivery(int id) { var delivery = await _context.Deliveries.FindAsync(id); if (delivery == null) { return(null); } return(new DeliveryViewModel { IdSale = delivery.IdSale, IdClient = delivery.IdClient, Adress = delivery.Adress, Date = _context.Entry(delivery).Property <DateTime>("DateOn").CurrentValue, State = delivery.State }); }
public async Task <OrderViewModel> GetOrderIncome(int id) { var order = await _context.OrderIncomes.FindAsync(id); if (order == null) { return(null); } return(new OrderViewModel { IdOrderIncome = order.IdOrderIncome, IdProvider = order.IdProvider, Proveedor = order.Provider.ProviderName, IdUser = order.IdUser, User = order.User.UserName, DateEntry = _context.Entry(order).Property <DateTime>("DateOn").CurrentValue, Total = order.Total, State = order.State }); }