/// <summary>
 /// Delete expense record from datase
 /// </summary>
 /// <param name="userId">User identifier</param>
 /// <param name="entity">Expense record identifier</param>
 /// <returns>Execution result</returns>
 public Response Delete(int userId, ExpenseRecord entity)
 {
     var response = new Response();
     if (HasUserAccess(userId, entity.Id))
     {
         context.ExpenseRecords.DeleteObject(entity);
         context.Save();
     }
     else
     {
         response.IsError = true;
         response.Errors.Add(Error.UserDoesNotHaveAccess);
     }
     return response;
 }
 /// <summary>
 /// Add new expense record to database
 /// </summary>
 /// <param name="userId">User Identifier</param>
 /// <param name="entity">Expense record</param>
 /// <returns>Expense record identifier</returns>
 public AddResponse Add(int userId, ExpenseRecord entity)
 {
     var response = new AddResponse();
     if (entity == null)
     {
         response.Errors.Add(Error.ExpenseRecordHasNotBeenSet);
         response.IsError = true;
     }
     else
     {
         context.ExpenseRecords.AddObject(entity);
         context.Save();
         response.Id = entity.Id;
     }
     return response;
 }
        /// <summary>
        /// Add expense record to the system
        /// </summary>
        /// <param name="userId">User identifier</param>
        /// <param name="description">Description for expense record</param>
        /// <param name="price">Price</param>
        /// <param name="tagId">Tag identifier for expense record</param>
        /// <param name="dateStamp">Date stamp which shows when money were spent</param>
        /// <returns>Executin result as Response object</returns>
        public Response Add(int userId, string description, decimal price, int tagId, DateTime? dateStamp)
        {
            var response = new AddResponse();

            if (string.IsNullOrEmpty(description) || price == 0 || tagId == 0 || dateStamp == null)
            {
                response.IsError = true;
                response.Errors.Add(Error.ExpenseRecordHasNotBeenSet);
            }
            else
            {
                var expenseRecord = new ExpenseRecord();
                var tagRepository = new TagRepository(context);
                expenseRecord.Tag = tagRepository.GetById(userId, tagId).Object;
                expenseRecord.Description = description;
                expenseRecord.Price = price;
                expenseRecord.DateStamp = (DateTime)dateStamp;
                response = Add(userId, expenseRecord);
            }
            return response;
        }