public JsonResult SubscribeBook([FromBody] CreateSubscriptionViewModel SubsModel) { var newsubs = new Subscription() { EndDate = SubsModel.EndDate, IsActive = true, PlanID = SubsModel.PlanId, StartDate = DateTime.Now, UserID = SubsModel.UserId }; sbsc.Subscriptions.Add(newsubs); sbsc.SaveChanges(); return(Json(newsubs)); }
public IActionResult Create(CreateSubscriptionViewModel model) { if (ModelState.IsValid) { var context = new ApplicationContext(); var subscription = new Subscription() { Name = model.Name, Description = model.Description, Price = model.Price }; context.Subscriptions.Add(subscription); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }