public HttpResponseMessage InsertNewUserLog(NewUserLogInsertRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } try { bool isSuccess = LogService.CreateNewLog(model); if (isSuccess) { var response = new ItemResponse <bool> { Item = isSuccess }; return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to Process Request.")); } } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)); } }
public static bool CreateNewLog(string userId, NewUserLogInsertRequest model) { bool isSuccess = true; // verify log does not already exist LogStatusType logStatus = LogService.Data.GetLogStatus(userId); if (logStatus != LogStatusType.NewUser) { throw new ApplicationException("A log already exists for the current user."); } DateTime today = DateTime.Today; DateTime startOfThisYear = LogService.GetYearStartOfDate(today); DateTime startOfThisMonth = LogService.GetMonthStartOfDate(today); string defaultMonthGoalType = "Fixed"; int defaultMonthFixedGoal = 100; var firstMonth = new DbMonth( monthId: 0, userId: userId, startDate: startOfThisMonth, grossCredits: 0, grossDebits: 0, startAmount: model.StartAmount, previousMonthId: null, isStartAmountConfirmed: true); try { // Create Preferences LogService.Data.InsertUserPreferences(userId, defaultMonthGoalType, defaultMonthFixedGoal); // Create Year LogService.Data.InsertYear(userId, startOfThisYear, model.StartAmount, model.YearGoal); // Create Month LogService.Data.InsertDbMonth(firstMonth); // Create Categories LogService.Data.SetDefaultCategories(userId); } catch (Exception e) { isSuccess = false; throw e; } return(isSuccess); }
public static bool CreateNewLog(NewUserLogInsertRequest newLogRequest) { bool isSuccess = false; try { string userId = UserService.GetCurrentUserId(); Log.CreateNewLog(userId, newLogRequest); isSuccess = true; } catch (Exception e) { throw e; } return(isSuccess); }
public static bool SetNewYearsGoal(NewUserLogInsertRequest newLogRequest) { bool isSuccess = false; try { string userId = UserService.GetCurrentUserId(); Data.UpdateYearGoalPreferences(newLogRequest); DateTime decemberFirst = GetYearStartOfDate(DateTime.Today).AddMonths(-1); TopOffLogToDate(userId, decemberFirst); isSuccess = true; } catch (Exception e) { throw e; } return(isSuccess); }
// --| User Log |--------------------------------------------------------------------------> public static bool InitializeUserLog(NewUserLogInsertRequest model) { bool isSuccess = false; //try //{ // DataProvider.ExecuteNonQuery(GetConnection, "dbo.Insert_FreshYearAndMonth", // inputParamMapper: delegate (SqlParameterCollection paramCollection) // { // paramCollection.AddWithValue("@UserId", model.UserId); // paramCollection.AddWithValue("@StartingDate", model.StartDate); // paramCollection.AddWithValue("@StartingAmount", model.StartingAmount); // paramCollection.AddWithValue("@YearGoal", model.GoalAmount); // isSuccess = true; // }); //} //catch (Exception e) //{ // throw e; //} return(isSuccess); }
public static void UpdateYearGoalPreferences(NewUserLogInsertRequest newLogRequest) { throw new NotImplementedException(); }