using BuddyFinance.Integration.Models.Enums; using System; namespace BuddyFinance.Integration.Mappers { public static class ManageCash { public static Model.CashWithdrawal MapToEntityModel(this Models.ManageCash.WithdrawalRequestModel viewModel, double amount) { if (viewModel == null) return null; return new BuddyFinance.Model.CashWithdrawal { Id = viewModel.Id, Amount = amount, Comment = viewModel.Comment, Date = viewModel.Id == 0 ? DateTime.Now : viewModel.Date, StatusId = viewModel.Id == 0 ? (int)CashWithdrawalEnum.Pending : viewModel.Status, ProfileId = viewModel.ProfileId }; } public static Models.ManageCash.WithdrawalRequestModel MapFrom(Model.CashWithdrawal model) { if (model == null) return null; return new Models.ManageCash.WithdrawalRequestModel { Id = model.Id, Amount = model.Amount, Comment = model.Comment, Date = model.Date, Status = model.StatusId, ProfileId = model.ProfileId }; } } }