private static void SeedUsers(SharpStoreContext context) { IList <User> users = new List <User>(); users.Add(new User() { Username = "******", Email = "*****@*****.**" }); users.Add(new User() { Username = "******", Email = "*****@*****.**" }); users.Add(new User() { Username = "******", Email = "*****@*****.**" }); users.Add(new User() { Username = "******", Email = "*****@*****.**" }); users.Add(new User() { Username = "******", Email = "*****@*****.**" }); foreach (User user in users) { context.Users.AddOrUpdate(u => u.Username, user); } context.SaveChanges(); System.Console.WriteLine("Users was added successfuly!"); }
private static void SeedKnifes(SharpStoreContext context) { IList <Knife> knives = new List <Knife>(); knives.Add(new Knife() { Name = "Knive Sharp One", Price = 267.55m, ImageURL = "images/sharp3.png" }); knives.Add(new Knife() { Name = "Knive Sharp Second", Price = 467.99m, ImageURL = "images/sharp4.jpg" }); knives.Add(new Knife() { Name = "Other Sharp", Price = 99m, ImageURL = "images/sharp5.jpg" }); knives.Add(new Knife() { Name = "Some Knive", Price = 111.87m, ImageURL = "images/knife-sharp1.jpg" }); knives.Add(new Knife() { Name = "Any Knive", Price = 900.99m, ImageURL = "images/knife-sharp2.jpg" }); foreach (Knife knive in knives) { context.Knives.AddOrUpdate(k => k.Name, knive); } context.SaveChanges(); System.Console.WriteLine("Knives was added successfuly!"); }
public static void HandleContactsPost(string incomingRequestString) { PostParameters = DecodeParams(incomingRequestString); var context = new SharpStoreContext(); Message message = new Message() { Sender = PostParameters["email"], Subject = PostParameters["subject"], Content = PostParameters["content"] }; context.Messages.Add(message); context.SaveChanges(); }
public IActionResult Reply(HttpResponse response, MessageBindingModel bmm) { var message = new Message() { Content = bmm.Content, Sender = "Admin", Subject = bmm.Subject }; context.Messages.Add(message); context.SaveChanges(); Redirect(response, "/admin/messages"); return(null); }
private static void UploadMessageInDB(HttpRequest request, SharpStoreContext context) { string requestContent = WebUtility.UrlDecode(request.Content); string[] parameters = requestContent.Split('&'); Dictionary <string, string> nameValuePair = new Dictionary <string, string>(); foreach (var parameter in parameters) { string[] parameterInfo = parameter.Split('='); nameValuePair.Add(parameterInfo[0], parameterInfo[1]); } Message message = new Message() { Sender = nameValuePair["emailAddress"], Subject = nameValuePair["subject"], FullMessage = nameValuePair["message"] }; context.Messages.Add(message); context.SaveChanges(); }
public IActionResult Contacts(Message message) { context.Messages.Add(message); context.SaveChanges(); return(this.View()); }