public Message Update(Expense expense) { Message msg = new Message(); try { var model = _expenseRepository.FindBy(x => x.Id == expense.Id).FirstOrDefault(); model.ModifiedAt = DateTime.Now; if (model == null) { throw new ArgumentException(); } expense.ToDalEntity(model); _expenseRepository.Edit(model); _expenseRepository.SaveChanges(); msg.StatusCode = 200; msg.Status = "Category Updated Successfully!"; } catch (Exception ex) { msg.StatusCode = 400; msg.Status = "An error occured while updating category."; } return(msg); }