public IActionResult CreateEvent(Event eventInfo) { if (isLoggedIn()) { if (ModelState.IsValid) { setSessionViewData(); User user = _context.users.SingleOrDefault(u => u.UserId == (int)ViewData["UserId"]); eventInfo.Coordinator = user; _context.events.Add(eventInfo); _context.event_volunteers.Add(new EventVolunteer { EventId = eventInfo.EventId, UserId = (int)ViewData["UserId"] }); _context.SaveChanges(); return(RedirectToAction("CreateLocation", "Create", new { EventId = eventInfo.EventId })); // return RedirectToAction("Dashboard", "Details", new { id = eventInfo.EventId }); // Dashboard.cshtml, View Details, Controller Details (Mark's) } } else { return(RedirectToAction(_action, _controller)); } return(View("New", eventInfo)); }
public IActionResult Post([FromBody] Listing listing) { var newListing = db.Listings.Add(listing); db.SaveChanges(); return(CreatedAtRoute("GetListing", new { id = listing.Id }, listing)); }
public IActionResult Post([FromBody] Account account) { var newAccount = db.Accounts.Add(account); db.SaveChanges(); return(CreatedAtRoute("GetAccount", new { id = account.Id }, account)); }
public JsonResult AddLocation([FromBody] Location location) { _context.locations.Add(location); _context.SaveChanges(); return(Json(new{ EventId = location.EventId, LocationId = location.LocationId })); }
public ActionResult Create([Bind(Include = "Email,FirstName,LastName,Username,Password,Center,Interests,Availability,Address,PhoneNumber,Education,Licenses,EMCname,EMCphone,EMCemail,EMCaddress,DriversLicenseOnFile,SocialCardOnFile,ApprovalStatus")] VolunteerModel volunteerModel) { if (ModelState.IsValid) { db.Volunteers.Add(volunteerModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteerModel)); }
public IActionResult CreateTask(TaskInfo task) { if (isLoggedIn()) { setSessionViewData(); _context.tasks.Add(task); _context.SaveChanges(); return(RedirectToAction("Dashboard", "Details", new { id = task.EventId })); } else { return(RedirectToAction(_action, _controller)); } }
public ActionResult Edit(Volunteer volunteer) { VolunteerContext volunteerContext = new VolunteerContext(); volunteerContext.Entry(volunteer).State = System.Data.Entity.EntityState.Modified; volunteerContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Volunteer volunteer) { VolunteerContext volunteerContext = new VolunteerContext(); volunteerContext.Volunteers.Add(volunteer); volunteerContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int Id) { VolunteerContext volunteerContext = new VolunteerContext(); Volunteer volunteer = volunteerContext.Volunteers.Single(vol => vol.Id == Id); volunteerContext.Volunteers.Remove(volunteer); volunteerContext.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResponse create(Message message) { if (message == null) { return new JsonResponse { Error = -2, Message = "the message is null", Result = "failed" } } ; if (!ModelState.IsValid) { return new JsonResponse { Error = -4, Message = "the message is not valid", Result = "failed" } } ; db.Messages.Add(message); db.SaveChanges(); return(new JsonResponse()); }
public JsonResponse create(Chat chat) { if (chat == null) { return new JsonResponse { Error = -2, Message = "the chat is null", Result = "failed" } } ; if (!ModelState.IsValid) { return new JsonResponse { Error = -7, Message = "the chat is not valid", Result = "failed" } } ; db.Chats.Add(chat); db.SaveChanges(); return(new JsonResponse()); }
public JsonResponse create(Forum forum) { if (forum == null) { return new JsonResponse { Error = -2, Message = "the forum is null", Result = "failed" } } ; if (!ModelState.IsValid) { return new JsonResponse { Error = -4, Message = "the forum is valid", Result = "failed" } } ; db.Forums.Add(forum); db.SaveChanges(); return(new JsonResponse()); }
public JsonResponse Add(User user, Event @event) { if (@event == null || user == null) { return new JsonResponse { Error = "null", Message = "Data has null values", Result = "Failed" } } ; if (user.IsAdmin == false) { return new JsonResponse { Error = "not admin", Message = "User cannot create event", Result = "failed" } } ; db.Events.Add(@event); db.SaveChanges(); return(new JsonResponse()); }
public JsonResponse Add(User user) { if (user == null) { return new JsonResponse { Error = "null", Message = "Null user", Result = "Failed" } } ; if (!ModelState.IsValid) { return new JsonResponse { Error = "not valid", Message = "non valid user", Result = "failed" } } ; db.Users.Add(user); db.SaveChanges(); return(new JsonResponse()); }
public JsonResponse create(Comment comment) { if (comment == null) { return new JsonResponse { Error = -2, Message = "the comment is null", Result = "failed" } } ; if (!ModelState.IsValid) { return new JsonResponse { Error = -4, Message = "the comment isnt valid", Result = "failed" } } ; db.Comments.Add(comment); db.SaveChanges(); return(new JsonResponse()); }
public void Adding_a_project() { using (VolunteerContext context = new VolunteerContext()) { Project project = new Project(); project.Name = "test"; project.Description = " some decription "; project.State = ProjectState.Open; context.Projects.Add(project); context.SaveChanges(); } }
public void Adding_a_project() { using (VolunteerContext context = new VolunteerContext()) { Project project = new Project(); project.Name = "test"; project.Description = " some decription "; project.State = ProjectState.Open; context.Projects.Add(project); context.SaveChanges(); } }
private void InitializeContext() { //This is a 'Global' Arrange. var builder = new DbContextOptionsBuilder <VolunteerContext>() .UseInMemoryDatabase(); var context = new VolunteerContext(builder.Options); var listings = Enumerable.Range(1, 10) .Select(i => new Listing { Id = i, EventName = $"Outreach{i}", ProducerName = "United" }); context.Listings.AddRange(listings); int changed = context.SaveChanges(); Db = context; }
public void Commit() { dataContext.SaveChanges(); }