public ActionResult Add(string EventTitle, string EventDescription, string EventLocation, string EventHostingDepartment, string EventDate, string EventTime, int CampusID) { Event NewEvent = new Event(); NewEvent.EventTitle = EventTitle; NewEvent.EventDescription = EventDescription; NewEvent.EventLocation = EventLocation; NewEvent.EventHostingDepartment = EventHostingDepartment; // SRC: Christine Bittle: MVC PetGrooming https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings // PURPOSE: Put both date and time values in one record // Unable to convert string value less 10:00 to Hmm so need to force a leading 0: int EventTimeInt = Int32.Parse(EventTime); if (EventTimeInt < 1000) { EventTime = "0" + EventTime; } Debug.WriteLine(EventDate + " " + EventTime); NewEvent.EventDate = DateTime.ParseExact(EventDate + " " + EventTime, "yyyy-MM-dd Hmm", System.Globalization.CultureInfo.InvariantCulture); NewEvent.CampusID = CampusID; // LINQ equivalent to Insert Statement and save to DB: db.Events.Add(NewEvent); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Add(string SenderFirstname, string SenderLastname, string SenderEmail, string PatientFirstname, string PatientLastname, string CardMessage, string PatientRoom, int CampusID, string CardImage) { PatientEcard patientecard = new PatientEcard(); patientecard.SenderFirstname = SenderFirstname; patientecard.SenderLastname = SenderLastname; patientecard.SenderEmail = SenderEmail; patientecard.PatientFirstname = PatientFirstname; patientecard.PatientLastname = PatientLastname; patientecard.CardMessage = CardMessage; patientecard.PatientRoom = PatientRoom; patientecard.CampusID = CampusID; patientecard.CardImage = CardImage; patientecard.DateSubmitted = DateTime.Now; patientecard.DateDelivered = null; // Equivalent to SQL insert statement: db.PatientEcards.Add(patientecard); db.SaveChanges(); //string redirectstring = "?PatientCardID=" + patientecard.PatientCardID; return(RedirectToAction("Confirm/", new { id = patientecard.PatientCardID })); }
public ActionResult Update([Bind(Include = "ServiceTitle,ServiceCategory")] ServiceModel services) { if (ModelState.IsValid) { db.Entry(services).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(services)); }
public ActionResult Add(String newSpeciality) { Speciality NewSpeciality = new Speciality { SpecialityName = newSpeciality }; db.Speciality.Add(NewSpeciality); db.SaveChanges(); return(Redirect("/Doctor/Add")); }
public ActionResult Add(String newFaqCatName) { FaqCategory category = new FaqCategory() { FaqCatName = newFaqCatName }; db.FaqCategories.Add(category); db.SaveChanges(); return(Redirect("/Faq/Add")); }
public ActionResult Create([Bind(Include = "EmergencyId,Date,Title,Article,KeywordOne,KeywordTwo,KeywordThree")] EmergencyModels emergency) { if (ModelState.IsValid) { db.Emergency.Add(emergency); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emergency)); }
public ActionResult Create([Bind(Include = "DonatorName,DonatorEmail,DonationDate,DonatorPhone,DonationAmount")] DonationModel donation) { if (ModelState.IsValid) { //creating a new donation Debug.WriteLine("adding the donation" + donation); db.Donation.Add(donation); db.SaveChanges(); return(RedirectToAction("List")); } return(View(donation)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, UserGender = model.UserGender, Address = model.Address, Province = model.Province, City = model.City, PostalCode = model.PostalCode, UserType = model.UserType, PhoneNumber = model.PhoneNumber }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); HospitalProjectContext db = new HospitalProjectContext(); if (model.UserType == ApplicationUser.Type.Patient) { Patient patient = new Patient(); patient.UserId = user.Id; db.Patients.Add(patient); db.SaveChanges(); } else if (model.UserType == ApplicationUser.Type.Doctor) { Doctor doctor = new Doctor(); doctor.UserId = user.Id; db.Doctors.Add(doctor); db.SaveChanges(); } else if (model.UserType == ApplicationUser.Type.Volunteer) { Volunteer volunteer = new Volunteer(); volunteer.UserId = user.Id; db.Volunteers.Add(volunteer); db.SaveChanges(); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Add(int VolunteerID, int VolunteerPostingID, string VolunteerEducation, string VolunteerOccupation, int VolunteerExperience) { Application newapplication = new Application(); newapplication.VolunteerID = VolunteerID; newapplication.VolunteerPostingID = VolunteerPostingID; newapplication.Education = VolunteerEducation; newapplication.CurrentOccupation = VolunteerOccupation; newapplication.Experience = VolunteerExperience; //first add application db.Applications.Add(newapplication); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Create([Bind(Include = "JobTitle,JobDepartmentName,JobPostedDate,JobDescription,JobRequirements")] JobModel job) { if (ModelState.IsValid) { Debug.WriteLine("adding the job" + job); //adding job db.Job.Add(job); //saving the changes to database db.SaveChanges(); //redirecting to list view return(RedirectToAction("List")); } return(View(job)); }
public ActionResult Create([Bind(Include = "ApplicantFirstName,ApplicantLastName,ApplicantAddress,ApplicantEmail,ApplicantPhone,ApplicantEducationSummary,ApplicantWorkExperience,ApplicantSkills")] ApplicantModel applicant) { //if the model state is valid then we can add the applicant if (ModelState.IsValid) { //adding applicant db.Applicant.Add(applicant); Debug.WriteLine("adding the applicant " + applicant); //saving changes db.SaveChanges(); return(RedirectToAction("List")); } return(View(applicant)); }
public ActionResult Add(String DocFirstname, String DocLastname, String DocEmailAddr, string DocLocation, String[] speciality) { //adding a new doctor Doctor NewDoctor = new Doctor { DocFname = DocFirstname, DocLname = DocLastname, DocEmail = DocEmailAddr, DocHLoc = DocLocation }; db.Doctor.Add(NewDoctor); var count = db.SaveChanges(); //attaching specialities of the doctor for (var i = 0; i < speciality.Length; i++) { string query = "insert into SpecialityDoctors(Speciality_SpecialityID,Doctor_DocID) values (@SpecialityID,@DocID)"; SqlParameter[] sqlparams = new SqlParameter[2]; sqlparams[0] = new SqlParameter("@SpecialityID", speciality[i]); sqlparams[1] = new SqlParameter("@DocID", NewDoctor.DocID); db.Database.ExecuteSqlCommand(query, sqlparams); } return(Redirect("/Doctor/List")); }
public ActionResult Add(string lostorfound, string item, string category, string color, string contactno, string note) { LostFound lostandfound = new LostFound(); DateTime now = DateTime.Now; lostandfound.LostorFound = lostorfound; lostandfound.LostFoundItem = item; lostandfound.LostFoundDate = now.ToString(); lostandfound.LostFoundCategory = category; lostandfound.LostFoundColor = color; lostandfound.LostFoundPerson = contactno; lostandfound.LostFoundNote = note; lostandfound.PatientID = 1.ToString(); db.lostFounds.Add(lostandfound); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Add(string doctorid, string datebooking, string patientid) { //Debug.WriteLine(doctorid + datebooking + patientid); //string BookingTime = "1200"; DateTime now = DateTime.Now; Debug.WriteLine(now); Booking book = new Booking(); book.DoctorID = doctorid; book.CurrentDate = now.ToString(); book.BookingDate = datebooking; book.PatientID = patientid; db.Bookings.Add(book); db.SaveChanges(); //return View(); return(RedirectToAction("List")); }
public ActionResult Add(string CampusName, string CampusAddressLine1, string CampusAddressLine2, string CampusCity, string CampusProvince, string CampusPC, string CampusPhone) { HospitalCampus NewCampus = new HospitalCampus(); NewCampus.CampusName = CampusName; NewCampus.CampusAddressLine1 = CampusAddressLine1; NewCampus.CampusAddressLine2 = CampusAddressLine2; NewCampus.CampusCity = CampusCity; NewCampus.CampusProvince = CampusProvince; NewCampus.CampusPC = CampusPC; NewCampus.CampusPhone = CampusPhone; // Equivalent to SQL insert statement: db.HospitalCampuses.Add(NewCampus); db.SaveChanges(); return(RedirectToAction("List")); }
public async Task <ActionResult> AddAppointment(string Username, string Userpass, string Useremail, string phoneNumber, string DoctorID, string PatientID, DateTime appointmentdate, string appointmentstatus) { Debug.WriteLine("reached inside add appointment method"); ApplicationUser NewUser = new ApplicationUser(); NewUser.UserName = Username; NewUser.Email = Useremail; NewUser.PhoneNumber = phoneNumber; string Id = NewUser.Id; string query = "INSERT INTO Appointments (appointmentdate, appointmentstatus) VALUES (@appointmentdate, @appointmentstatus)"; SqlParameter[] sqlparams = new SqlParameter[2]; sqlparams[0] = new SqlParameter("@appointmentdate", appointmentdate); sqlparams[1] = new SqlParameter("@appointmentstatus", appointmentstatus); db.Database.ExecuteSqlCommand(query, sqlparams); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Update(int id, string question, string answer) { //used LINQ FAQ faqs = db.FAQs.Find(id); faqs.question = question; faqs.answer = answer; db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Add(string Title, DateTime Date, string Body, bool Published) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Attemping to add a new post: " + Title); //create a new health library post HealthLibrary HealthLibrary = new HealthLibrary(); //bind passed in params HealthLibrary.Title = Title; HealthLibrary.Date = Date; HealthLibrary.Body = Body; HealthLibrary.Published = Published; //add to the db and save db.HealthLibraries.Add(HealthLibrary); db.SaveChanges(); //redirect to list view return(RedirectToAction("List")); }
public ActionResult Add(string Question, string Answer, bool Published) { //check if the user is logged in and is an admin and direct to login if they are not an admin or logged in //put the rest of the code in an else statement Debug.WriteLine("Attemping to add a new faq: " + Question); //create a new faq Faq Faq = new Faq(); //bind passed in params Faq.Question = Question; Faq.Answer = Answer; Faq.Published = Published; //add to the db and save db.Faqs.Add(Faq); db.SaveChanges(); //redirect to list view return(RedirectToAction("List")); }
public ActionResult Add(string title, string date, string content) { Article NewArticle = new Article(); NewArticle.title = title; NewArticle.date = DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture); NewArticle.content = content; db.Articles.Add(NewArticle); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult AddBooking(int doctorId, string bookingDateTime, string comments) { string userID = User.Identity.GetUserId(); if (string.IsNullOrEmpty(userID)) { return(RedirectToAction("Login", "Account")); } else { Patient patient = db.Patients.SqlQuery("select * from Patients where UserId = @id", new SqlParameter("@id", userID)).FirstOrDefault(); DoctorAppointment appointment = new DoctorAppointment(); appointment.DoctorID = doctorId; appointment.PatientComments = comments; appointment.PatientID = patient.PatientID; appointment.BookingDateTime = Convert.ToDateTime(bookingDateTime); // Equivalent to SQL insert statement: db.DoctorApointments.Add(appointment); db.SaveChanges(); return(RedirectToAction("Bookings")); } }
public ActionResult AddBooking(int parkingID, string bookingDateTime, int hours) { Debug.WriteLine(bookingDateTime); string userID = User.Identity.GetUserId(); if (string.IsNullOrEmpty(userID)) { return(RedirectToAction("Login", "Account")); } else { ParkingBooking booking = new ParkingBooking(); booking.ParkingID = parkingID; booking.Hours = hours; booking.UserId = User.Identity.GetUserId(); booking.BookingTime = Convert.ToDateTime(bookingDateTime); // Equivalent to SQL insert statement: db.ParkingBookings.Add(booking); db.SaveChanges(); return(RedirectToAction("Bookings")); } }
public ActionResult Add(string ServiceName, string ServiceDetails) { Service newservice = new Service(); //https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings newservice.ServiceName = ServiceName; newservice.ServiceDetails = ServiceDetails; db.Services.Add(newservice); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult AddJob(string Position, int jobTypeID, string Qualification, int Experience) { string userID = User.Identity.GetUserId(); if (string.IsNullOrEmpty(userID)) { return(RedirectToAction("Login", "Account")); } else { Job job = new Job(); job.JobTypeID = jobTypeID; job.Position = Position; job.Qualification = Qualification; job.Experience = Experience; // Equivalent to SQL insert statement: db.Jobs.Add(job); db.SaveChanges(); return(RedirectToAction("JobsListing")); } }
public ActionResult Add(int PatientID, int ServiceID, int Amount, string DateOfService, bool Status) { Invoice newinvoice = new Invoice(); newinvoice.PatientID = PatientID; newinvoice.ServiceID = ServiceID; newinvoice.Amount = Amount; newinvoice.DateOfService = Convert.ToDateTime(DateOfService); newinvoice.Status = Status; //first add invoice db.Invoices.Add(newinvoice); db.SaveChanges(); return(RedirectToAction("List")); }
public async Task <ActionResult> Add(string UserEmail, string UserPassword, string DoctorFName, string DoctorMName, string DoctorLName, DateTime DoctorDOB, string DoctorPhone, string DoctorAltPhone) { //before creating a doctor, we would like to create a user. //this user will be linked with a doctor. ApplicationUser NewUser = new ApplicationUser(); NewUser.UserName = UserEmail; NewUser.Email = UserEmail; //code interpreted from AccountController.cs Register Method IdentityResult result = await UserManager.CreateAsync(NewUser, UserPassword); if (result.Succeeded) { //need to find the user we just created -- get the ID string Id = NewUser.Id; //what was the id of the new account? //link this id to the Owner string DoctorID = Id; Doctor NewDoctor = new Doctor(); NewDoctor.DoctorID = Id; NewDoctor.DoctorFName = DoctorFName; NewDoctor.DoctorMName = DoctorMName; NewDoctor.DoctorLName = DoctorLName; NewDoctor.DoctorBirthDate = DoctorDOB; NewDoctor.DoctorPhone = DoctorPhone; NewDoctor.DoctorAltPhone = DoctorAltPhone; //SQL equivalent : INSERT INTO GROOMERS (GroomerFname, .. ) VALUES (@GroomerFname..) db.Doctors.Add(NewDoctor); db.SaveChanges(); } else { //Simple way of displaying errors ViewBag.ErrorMessage = "Something Went Wrong!"; ViewBag.Errors = new List <string>(); foreach (var error in result.Errors) { ViewBag.Errors.Add(error); } } return(View()); }
public async Task <ActionResult> Add(string Username, string phoneNumber, decimal donation_amount, string Useremail, string Userpass) { Debug.WriteLine("Inside Post method add"); ApplicationUser NewUser = new ApplicationUser(); NewUser.UserName = Username; NewUser.Email = Useremail; NewUser.PhoneNumber = phoneNumber; //code interpreted from AccountController.cs Register Method IdentityResult result = await UserManager.CreateAsync(NewUser, Userpass); if (result.Succeeded) { string Id = NewUser.Id; //what was the id of the new account? string query = "INSERT INTO Donations (DonationID, donor_mail, donation_amount, donated_on) VALUES (@DonationID, @donor_mail, @donation_amount, @donated_on)"; SqlParameter[] sqlparams = new SqlParameter[4]; sqlparams[0] = new SqlParameter("@donor_mail", Useremail); sqlparams[1] = new SqlParameter("@donation_amount", (int)(donation_amount)); sqlparams[2] = new SqlParameter("@donated_on", DateTime.Now); sqlparams[3] = new SqlParameter("@DonationID", Id); db.Database.ExecuteSqlCommand(query, sqlparams); db.SaveChanges(); return(RedirectToAction("List")); /* * * Donation newbooking = new Donation(); * newbooking.DonationID = Id; * newbooking.donated_on = DateTime.Now; * newbooking.donation_amount = ; * * //first add booking * db.Donation.Add(newbooking);*/ } else { //Simple way of displaying errors ViewBag.ErrorMessage = "Something Went Wrong!"; ViewBag.Errors = new List <string>(); foreach (var error in result.Errors) { ViewBag.Errors.Add(error); } } return(View()); }
public ActionResult Add(string VolunteerPostingDate, string VolunteerPostingTitle, string VolunteerPostingDescription) { VolunteerPosting newposting = new VolunteerPosting(); //https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings Debug.WriteLine(VolunteerPostingDate); newposting.VolunteerPostingDate = Convert.ToDateTime(VolunteerPostingDate); newposting.VolunteerPostingTitle = VolunteerPostingTitle; newposting.VolunteerPostingDescription = VolunteerPostingDescription; //first add posting db.VolunteerPostings.Add(newposting); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult AddDonation(string DonorFirstName, string DonorLastName, string DonorEmail, string DonorPhone, string DonorAddress, string DonorCity, string DonorProvince, int DonationAmount) { Donation Donation = new Donation(); Donation.DonorFirstName = DonorFirstName; Donation.DonorLastName = DonorLastName; Donation.DonorEmail = DonorEmail; Donation.DonorPhone = DonorPhone; Donation.DonorAddress = DonorAddress; Donation.DonorCity = DonorCity; Donation.DonorProvince = DonorProvince; Donation.DonationAmount = DonationAmount; Donation.DonationDate = DateTime.Now; db.Donations.Add(Donation); db.SaveChanges(); return(RedirectToAction("DonationSuccess")); }
public async Task <ActionResult> Add(string Username, string phoneNumber, string volunteerSpecialization, string Useremail, string Userpass) { Debug.WriteLine("Inside Post method add"); //christine pet groomer for reference ApplicationUser NewUser = new ApplicationUser(); NewUser.UserName = Username; NewUser.Email = Useremail; NewUser.PhoneNumber = phoneNumber; //code interpreted from AccountController.cs Register Method IdentityResult result = await UserManager.CreateAsync(NewUser, Userpass); if (result.Succeeded) { //we need to find the register user we just created -- get the ID of particular user string Id = NewUser.Id; //what was the id of the new account? //link this id to the Volunteer string volunteer_id = Id; string volunteer_status = "Waiting"; VolunteerRecruitment NewVol = new VolunteerRecruitment(); NewVol.volunteer_id = Id; NewVol.volunteer_specialization = volunteerSpecialization; NewVol.volunteer_status = volunteer_status; //LINQ //SQL equivalent : INSERT INTO volunteerRecruitment (volunteer_id, .. ) VALUES (@id..) db.volunteerRecruitment.Add(NewVol); db.SaveChanges(); return(RedirectToAction("List")); } else { //Simple way of displaying errors ViewBag.ErrorMessage = "Something Went Wrong!"; ViewBag.Errors = new List <string>(); foreach (var error in result.Errors) { ViewBag.Errors.Add(error); } } return(View()); }