/// <summary> /// Update model, so we can update an expense Type(ENUM) using letters /// </summary> /// <param name="expensePostModel">Model received from "input"</param> /// <returns>added Expense</returns> public static Expenses ToUpdateExpenses(ExpensesPostModel expensePostModel, Expenses expense) { Models.Type type = new Models.Type(); if (expensePostModel.Type == "Food") { type = Models.Type.Food; } else if (expensePostModel.Type == "Utilities") { type = Models.Type.Utilities; } else if (expensePostModel.Type == "Outing") { type = Models.Type.Outing; } else if (expensePostModel.Type == "Groceries") { type = Models.Type.Groceries; } else if (expensePostModel.Type == "Clothes") { type = Models.Type.Clothes; } else if (expensePostModel.Type == "Transport") { type = Models.Type.Transport; } else if (expensePostModel.Type == "Other") { type = Models.Type.Other; } else { return(null); } expense.Description = expensePostModel.Description; expense.Sum = expensePostModel.Sum; expense.Location = expensePostModel.Location; expense.Date = expensePostModel.Date; expense.Currency = expensePostModel.Currency; expense.Type = type; expense.Comments = expensePostModel.Comments; return(expense); }
/// <summary> /// Add model, so we can add Type(ENUM) using letters /// </summary> /// <param name="expenses">Model received from "input"</param> /// <returns>added Expense</returns> public static Expenses ToExpenses(ExpensesPostModel expenses) { Models.Type type = new Models.Type(); if (expenses.Type == "Food") { type = Models.Type.Food; } else if (expenses.Type == "Utilities") { type = Models.Type.Utilities; } else if (expenses.Type == "Outing") { type = Models.Type.Outing; } else if (expenses.Type == "Groceries") { type = Models.Type.Groceries; } else if (expenses.Type == "Clothes") { type = Models.Type.Clothes; } else if (expenses.Type == "Transport") { type = Models.Type.Transport; } else if (expenses.Type == "Other") { type = Models.Type.Other; } else { return(null); } return(new Expenses { Description = expenses.Description, Sum = expenses.Sum, Location = expenses.Location, Date = expenses.Date, Currency = expenses.Currency, Type = type, Comments = expenses.Comments }); }