/// <summary> /// Creates a new user profile entry /// </summary> /// <param name="model"></param> /// <param name="file"></param> /// <param name="popupFile"></param> public void CreateProfileEntry(RockstarProfile model, HttpPostedFileBase file, HttpPostedFileBase popupFile) { dbContext = new RockstarDBModelDataContext(); RockstarProfile dbModel = model; DateTime now = DateTime.UtcNow; DateTime localNow = TimeZoneInfo.ConvertTimeFromUtc(now, TimeZoneInfo.Local); if (file != null) { byte[] fileData = new byte[file.InputStream.Length]; file.InputStream.Read(fileData, 0, fileData.Length); dbModel.ProfilePic = fileData; } if (popupFile != null) { byte[] popupData = new byte[popupFile.InputStream.Length]; popupFile.InputStream.Read(popupData, 0, popupData.Length); dbModel.PopupLayout = popupData; } dbModel.CreatedOn = localNow; dbContext.RockstarProfiles.InsertOnSubmit(dbModel); dbContext.SubmitChanges(); }
public ActionResult EditProfileEntry(RockstarProfile model, HttpPostedFileBase file, HttpPostedFileBase popupFile) { ProfileService svc = new ProfileService(); svc.EditProfileRecord(model, file, popupFile); return(Redirect("/Account/ProfileTool?GUID=" + AdminToolsGUID)); }
public void DeleteBlogRecord(int id) { dbContext = new RockstarDBModelDataContext(); RockstarProfile profileItem = dbContext.RockstarProfiles.Where(p => p.Id == id).FirstOrDefault(); dbContext.RockstarProfiles.DeleteOnSubmit(profileItem); dbContext.SubmitChanges(); }
/// <summary> /// Returns profile by id /// </summary> /// <param name="id"></param> /// <returns></returns> public RockstarProfile ReadProfileByID(int id) { dbContext = new RockstarDBModelDataContext(); RockstarProfile model = (from b in dbContext.RockstarProfiles where b.Id == id select b).FirstOrDefault(); return(model); }
/// <summary> /// Update profile record /// </summary> /// <param name="model"></param> /// <param name="file"></param> /// <param name="popupFile"></param> public void EditProfileRecord(RockstarProfile model, HttpPostedFileBase file, HttpPostedFileBase popupFile) { dbContext = new RockstarDBModelDataContext(); RockstarProfile oldProfile = dbContext.RockstarProfiles.Where(o => o.Id == model.Id).FirstOrDefault(); DateTime now = DateTime.UtcNow; DateTime localNow = TimeZoneInfo.ConvertTimeFromUtc(now, TimeZoneInfo.Local); // Profile parameters oldProfile.FirstName = model.FirstName; oldProfile.LastName = model.LastName; oldProfile.DOB = model.DOB; oldProfile.UniversityCollege = model.UniversityCollege; oldProfile.Program = model.Program; oldProfile.GradYear = model.GradYear; oldProfile.Hometown = model.Hometown; oldProfile.Organization = model.Organization; oldProfile.Title = model.Title; oldProfile.Associates = model.Associates; oldProfile.Email = model.Email; oldProfile.Twitter = model.Twitter; oldProfile.Facebook = model.Facebook; oldProfile.Phone = model.Phone; oldProfile.LinkedIn = model.LinkedIn; oldProfile.Instagram = model.Instagram; oldProfile.Skype = model.Skype; oldProfile.PositiveChangeQuestion = model.PositiveChangeQuestion; oldProfile.LearnQuestion = model.LearnQuestion; oldProfile.ExampleQuestion = model.ExampleQuestion; oldProfile.ImpactQuestion = model.ImpactQuestion; oldProfile.AdditonalQuestion = model.AdditonalQuestion; oldProfile.YoutubeLink = model.YoutubeLink; //File info save if (file != null) { byte[] fileData = new byte[file.InputStream.Length]; file.InputStream.Read(fileData, 0, fileData.Length); oldProfile.ProfilePic = fileData; } if (popupFile != null) { byte[] popupData = new byte[popupFile.InputStream.Length]; popupFile.InputStream.Read(popupData, 0, popupData.Length); oldProfile.PopupLayout = popupData; } oldProfile.CreatedOn = localNow; dbContext.SubmitChanges(); }
/// <summary> /// Edit profile entry view /// </summary> /// <param name="GUID"></param> /// <param name="Id"></param> /// <returns></returns> public ActionResult EditProfileEntry(string GUID, int Id) { if (!(String.IsNullOrEmpty(GUID)) && GUID.Equals(AdminToolsGUID)) { ProfileService svc = new ProfileService(); if (Id == 0) { return(View()); } else { RockstarProfile model = svc.ReadProfileByID(Id); return(View(model)); } } else { return(Redirect("/Home/Index")); } }
public ActionResult EditProfileEntry(RockstarProfile model, HttpPostedFileBase file, HttpPostedFileBase popupFile) { ProfileService svc = new ProfileService(); svc.EditProfileRecord(model, file, popupFile); return Redirect("/Account/ProfileTool?GUID=" + AdminToolsGUID); }