public NotificationResponse UpdatePlayerId(string PlayerId) { NotificationResponse objUpdatePlayerId = new NotificationResponse(); try { var headers = Request.Headers; string token = headers.Authorization.Parameter.ToString(); Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("select UserId from UserToken where TokenCode={0}", token).FirstOrDefault(); var _UpdatePlayerId = _objFriendFitDBEntity.UserProfiles.Where(x => x.Id == UserId).FirstOrDefault(); _UpdatePlayerId.DeviceId = PlayerId; _UpdatePlayerId.DeviceTypeId = 3; _objFriendFitDBEntity.Entry(_UpdatePlayerId).State = System.Data.Entity.EntityState.Modified; _objFriendFitDBEntity.SaveChanges(); objUpdatePlayerId.Responses.Message = "Player Id is Updated Successfully."; objUpdatePlayerId.Responses.StatusCode = 200; } catch (Exception ex) { objUpdatePlayerId.Responses.Message = Convert.ToString(ex); objUpdatePlayerId.Responses.StatusCode = 501; } return(objUpdatePlayerId); }
public int AddWorkout(AddWorkoutModelRequest objAddWorkoutModelRequest, Int64 UserId) { WorkOut objWork = new WorkOut() { UserId = objAddWorkoutModelRequest.UserId, Description = objAddWorkoutModelRequest.Description, DateOfWorkout = objAddWorkoutModelRequest.DateOfWorkout, StartTime = objAddWorkoutModelRequest.StartTime, FinishTime = objAddWorkoutModelRequest.FinishTime, WorkoutNotes = objAddWorkoutModelRequest.WorkoutNotes, Createdate = System.DateTime.Now, CreatedBy = UserId, IsActive = true, RowStatus = true, StatusId = 2, AutoFinishTime = objAddWorkoutModelRequest.AutoFinishTime, ScheduleWorkout = false }; _objFriendFitDBEntity.WorkOuts.Add(objWork); _objFriendFitDBEntity.SaveChanges(); return(1); }
public HttpResponseMessage Login(LoginModelRequest objLoginModelRequest) { LoginModelResponse result = new LoginModelResponse(); if (ModelState.IsValid) { try { Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("Select Id from UserProfile where Email={0}", objLoginModelRequest.Email).FirstOrDefault(); bool mailVerified = _objFriendFitDBEntity.Database.SqlQuery <bool>("select EmailConfirmed from UserProfile where Id={0}", UserId).FirstOrDefault(); if (mailVerified == false) { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotAcceptable); result.Response.Message = "Please Verify Your Email Id that has been sent to your mail."; } else { result.Response = _objIUserSettings.Login(objLoginModelRequest); //Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery<Int64>("select Id from UserProfile where Email={0}", objLoginModelRequest.Email).FirstOrDefault(); if (result.Response != null) { string Token = _objFriendFitDBEntity.Database.SqlQuery <string>("select TokenCode from UserToken where UserId={0}", UserId).FirstOrDefault(); if (Token == null || Token == "0") { if (Token == null) { UserToken objToken = new UserToken() { UserId = result.Response.Id, RoleId = result.Response.RoleId, CreatedOn = DateTime.Now, IsActive = true, ExpiryDate = DateTime.Now.AddDays(7), TokenCode = Guid.NewGuid().ToString() + result.Response.Id.ToString() + Guid.NewGuid().ToString() }; _objFriendFitDBEntity.UserTokens.Add(objToken); _objFriendFitDBEntity.SaveChanges(); result.Response.TokenCode = objToken.TokenCode; } else { int rowEffected = _objFriendFitDBEntity.Database.ExecuteSqlCommand("Update Token set TokenCode=@TokenCode,ExpiryDate=@ExpiryDate where UserId=@UserId", new SqlParameter("TokenCode", Guid.NewGuid().ToString() + result.Response.Id.ToString() + Guid.NewGuid().ToString()), new SqlParameter("ExpiryDate", DateTime.Now.AddDays(7)), new SqlParameter("UserId", UserId)); } } else { result.Response.TokenCode = Token; } result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.OK); result.Response.Message = "You are logged in successfully!"; } else { var GetIsActive = _objFriendFitDBEntity.UserProfiles.Where(a => a.Password == objLoginModelRequest.Password && a.Email == objLoginModelRequest.Email).FirstOrDefault(); if (GetIsActive != null) { var IsActive = _objFriendFitDBEntity.UserProfiles.Where(a => a.Password == objLoginModelRequest.Password && a.Email == objLoginModelRequest.Email && a.IsActive == true && a.IsDeleted == false).FirstOrDefault(); if (IsActive != null) { FResponse res = new FResponse(); res.StatusCode = Convert.ToInt32(HttpStatusCode.Unauthorized); res.Message = "Email or Password is Incorrect"; _response = Request.CreateResponse(HttpStatusCode.Unauthorized, res); } else { FResponse res = new FResponse(); res.StatusCode = Convert.ToInt32(HttpStatusCode.Unauthorized); res.Message = "Your Account is currently disabled kindly contact Admin."; _response = Request.CreateResponse(HttpStatusCode.Unauthorized, res); } } else { FResponse res = new FResponse(); res.StatusCode = Convert.ToInt32(HttpStatusCode.Unauthorized); res.Message = "Email or Password is Incorrect"; _response = Request.CreateResponse(HttpStatusCode.Unauthorized, res); } return(_response); } } } catch (Exception ex) { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.BadRequest); _response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Some error occurred"); } } else { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.BadRequest); _response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Model is not valid"); } //result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.OK); //result.Response.Message = "Success"; _response = Request.CreateResponse(HttpStatusCode.OK, result); return(_response); }
public int AddSchedule(AddScheduleRequestModel objAddScheduleRequestModel, Int64 UserId) { //TimeZoneInfo GetUTCTime = TimeZoneInfo.FindSystemTimeZoneById("Greenwich Mean Time"); //DateTime UTCTime = DateTime.UtcNow; //DateTime localDateTime = DateTime.Now.ToLocalTime(); //TimeSpan dd = (UTCTime - localDateTime); //TimeZoneInfo timeZoneInfo_india = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); //DateTime India = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo_india); //DateTime localDateTime = DateTime.Now.ToLocalTime(); //TimeSpan dd = (India - localDateTime); TimeSpan newtime; TimeSpan span3; //var GetCountryId = _objFriendFitDBEntity.UserProfiles.Where(s => s.Id == UserId).FirstOrDefault(); var GetCountryId = _objFriendFitDBEntity.UserProfiles.Where(s => s.Id == UserId).FirstOrDefault(); if (GetCountryId.CountryId == 91) { span3 = TimeSpan.FromMinutes(0); newtime = objAddScheduleRequestModel.ScheduleTime; } else { span3 = TimeSpan.FromMinutes(270); newtime = objAddScheduleRequestModel.ScheduleTime.Subtract(span3); if (newtime.TotalDays >= 1) { span3 = TimeSpan.FromDays(1); TimeSpan span5 = TimeSpan.FromMinutes(270); TimeSpan newtime1 = objAddScheduleRequestModel.ScheduleTime.Subtract(span3); newtime = newtime1.Subtract(span5); } } //var GetCountryId = _objFriendFitDBEntity.UserProfiles.Where(s => s.Id == UserId).FirstOrDefault(); //switch (GetCountryId.CountryId) //{ // case 1: //canada // span3 = TimeSpan.FromMinutes(300); // break; // case 2: // span3 = TimeSpan.FromMinutes(-330); // break; // case 44: //UK // span3 = TimeSpan.FromMinutes(0); // break; // case 61: //australia // span3 = TimeSpan.FromMinutes(-600); // break; // case 91: //india // span3 = TimeSpan.FromMinutes(-330); // break; // case 973: //BAHRAIN // span3 = TimeSpan.FromMinutes(-180); // break; // default: // span3 = TimeSpan.FromMinutes(-330); // break; //} //TimeSpan TImeSp = objAddScheduleRequestModel.ScheduleTime; //TimeSpan Start_UTCTime = TImeSp.Add(span3); //DateTime time = DateTime.Today.Add(newtime); //string displayTime = time.ToString("hh:mm tt"); //TimeSpan GetScdeduleTime = Convert.ToDateTime(displayTime).TimeOfDay; WorkOutSchedule objWorkOutSchedule = new WorkOutSchedule() { Monday = objAddScheduleRequestModel.Monday, Tuesday = objAddScheduleRequestModel.Tuesday, Wednesday = objAddScheduleRequestModel.Wednesday, Thursday = objAddScheduleRequestModel.Thursday, Friday = objAddScheduleRequestModel.Friday, Saturday = objAddScheduleRequestModel.Saturday, Sunday = objAddScheduleRequestModel.Sunday, RecurrenceId = objAddScheduleRequestModel.RecurrenceId, ScheduleTime = objAddScheduleRequestModel.ScheduleTime, ScheduleTime_UTC = newtime, TextMeTime = objAddScheduleRequestModel.TextMeTime, TextFriendTime = objAddScheduleRequestModel.TextFriendTime, StartDate = objAddScheduleRequestModel.StartDate, EndDate = objAddScheduleRequestModel.EndDate, CreatedDate = DateTime.Now, CreatedBy = UserId, IsActive = true, RowStatus = false, UserId = UserId, WorkoutId = 0, WorkoutText = objAddScheduleRequestModel.WorkoutText }; _objFriendFitDBEntity.WorkOutSchedules.Add(objWorkOutSchedule); _objFriendFitDBEntity.SaveChanges(); Int64 workoutId = _objFriendFitDBEntity.WorkOutSchedules.Where(x => x.WorkoutText == objWorkOutSchedule.WorkoutText).FirstOrDefault().Id; var BulkInsert = _objFriendFitDBEntity.InsertBulkworkout(Convert.ToInt32(workoutId)); return(Convert.ToInt32(workoutId)); }
public HttpResponseMessage ListOfInvitedFriend() { ListOfInvitedFriendResponse result = new ListOfInvitedFriendResponse(); try { var headers = Request.Headers; string token = headers.Authorization.Parameter.ToString(); Int64 UserId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("select UserId from UserToken where TokenCode={0}", token).FirstOrDefault(); //result.Response.listofFriends = _objIFriendInvitationRepository.ListOfInvitedFriend(UserId); List <ListOfInvitedFriends> obj = new List <ListOfInvitedFriends>(); obj = _objFriendFitDBEntity.Database.SqlQuery <ListOfInvitedFriends>("ListOfFriends @UserId=@UserId", new SqlParameter("UserId", UserId)).ToList(); var _ListOfInvitedFriends = _objFriendFitDBEntity.Database.SqlQuery <ListOfInvitedFriends>("ListOfFriends @UserId=@UserId", new SqlParameter("UserId", UserId)).Where(s => s.PaymentDone == 0).ToList(); foreach (var item in _ListOfInvitedFriends) { DateTime dt_CurrentDate = DateTime.Today.Date; DateTime dt_PurchaseDate = Convert.ToDateTime(item.PurchaseDate).Date; DateTime dt_ExpiryDate = Convert.ToDateTime(item.ExpiryDate).Date; DateTime New_dt_PurchaseDate; DateTime New_dt_ExpiryDate; if (dt_PurchaseDate < dt_CurrentDate) { double TotalDayDiff = (dt_CurrentDate - dt_PurchaseDate).TotalDays; New_dt_PurchaseDate = Convert.ToDateTime(item.PurchaseDate).Date.AddDays(TotalDayDiff); New_dt_ExpiryDate = Convert.ToDateTime(item.ExpiryDate).Date.AddDays(TotalDayDiff); var UpdateFriendsInvitations = _objFriendFitDBEntity.FriendsInvitations.Where(x => x.Id == item.FriendId).FirstOrDefault(); UpdateFriendsInvitations.PurchaseDate = New_dt_PurchaseDate; UpdateFriendsInvitations.ExpiryDate = New_dt_ExpiryDate; _objFriendFitDBEntity.Entry(UpdateFriendsInvitations).State = System.Data.Entity.EntityState.Modified; _objFriendFitDBEntity.SaveChanges(); } } result.Response.listofFriends = _objFriendFitDBEntity.Database.SqlQuery <ListOfInvitedFriends>("ListOfFriends @UserId=@UserId", new SqlParameter("UserId", UserId)).ToList(); if (result.Response.listofFriends.Count > 0) { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.OK); result.Response.Message = "Success!"; } else { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.NotFound); result.Response.Message = "No Records"; } } catch (Exception ex) { result.Response.StatusCode = Convert.ToInt32(HttpStatusCode.BadRequest); _response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Some error occurred"); } _response = Request.CreateResponse(HttpStatusCode.OK, result); return(_response); }