public static void SavePlayer(string registrationNumber, string first, string last, string weight, string dateOfBirth, string level, int team) { decimal convertedWeight = 0.0m; try { convertedWeight = Convert.ToDecimal(weight); } catch (Exception ex) { } tbl_Player player = new tbl_Player() { FirstName = first, LastName = last, Weight = convertedWeight, RegistrationNumber = registrationNumber, DateOfBirth = DateTime.ParseExact(dateOfBirth, "M/d/yyyy h:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture), Team = team }; using (var context = new ActiveRosterDBEntities()) { context.tbl_Player.Add(player); context.SaveChanges(); } }
public static void SaveImage(string playerNumber, Image image) { using (var context = new ActiveRosterDBEntities()) { tbl_Player player = context.tbl_Player.Where(p => p.RegistrationNumber.Contains(playerNumber)).FirstOrDefault(); if (player != null) { player.Image = ImageHelper.ImageToByteArray(image); context.SaveChanges(); } } }