Beispiel #1
0
 public ActionResult MaintainDonor(Donor donor, string button)
 {
     if (button == "Save")
     {
         try
         {
             Donor Donor = db.Donors.Find(donor.Donor_ID);
             if (Donor == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 db.Entry(Donor).CurrentValues.SetValues(donor);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             return(RedirectToAction("MaintainDonor", "Donations"));
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult MaintainStock(Stock stock2, string button)
 {
     if (button == "Save")
     {
         try
         {
             Stock stock1 = db.Stocks.Find(stock2.Stock_ID);
             if (stock1 == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 db.Entry(stock1).CurrentValues.SetValues(stock2);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             return(RedirectToAction("MaintainStock", "Stock"));
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Beispiel #3
0
 public ActionResult MaintainFosterCareParent(Foster_Care_Parent foster_Care_Parent, string button)
 {
     if (button == "Save")
     {
         try
         {
             Foster_Care_Parent foster_Care_Parent1 = db.Foster_Care_Parent.Find(foster_Care_Parent.Foster_Parent_ID);
             if (foster_Care_Parent1 == null)
             {
                 return(HttpNotFound());
             }
             else
             {
                 db.Entry(foster_Care_Parent1).CurrentValues.SetValues(foster_Care_Parent);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ViewBag.err = e.Message;
             return(RedirectToAction("MaintainFosterCareParent", "Stock"));
         }
     }
     else if (button == "Cancel")
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult Edit([Bind(Include = "Kennel_ID,Kennel_Name,Kennel_Number,Kennel_Capacity")] Kennel kennel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kennel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kennel));
 }
 public ActionResult Edit([Bind(Include = "Event_Type_ID,Event_Type_Name")] Event_Type event_Type)
 {
     if (ModelState.IsValid)
     {
         db.Entry(event_Type).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(event_Type));
 }
 public ActionResult Edit([Bind(Include = "Vet_ID,Vet_Name,Vet_Emial,Vet_Tel,Vet_Address")] Veterinarian veterinarian)
 {
     if (ModelState.IsValid)
     {
         db.Entry(veterinarian).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(veterinarian));
 }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "Vol_WorkType_ID,Vol_WorkType_Name,Vol_WorkType_Description")] Volunteer_Work_Type volunteer_Work_Type)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volunteer_Work_Type).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(volunteer_Work_Type));
 }
 public ActionResult Edit([Bind(Include = "Contract_ID,Electronic_Contract,Adopter_ID")] Adopter_Contract adopter_Contract)
 {
     if (ModelState.IsValid)
     {
         db.Entry(adopter_Contract).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Adopter_ID = new SelectList(db.Adopters, "Adopter_ID", "Adopter_Name", adopter_Contract.Adopter_ID);
     return(View(adopter_Contract));
 }
 public ActionResult Edit([Bind(Include = "Vet_Appointment_ID,Vet_ID")] Vet_Appointment vet_Appointment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vet_Appointment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Vet_ID = new SelectList(db.Veterinarians, "Vet_ID", "Vet_Name", vet_Appointment.Vet_ID);
     return(View(vet_Appointment));
 }
Beispiel #10
0
 public ActionResult Edit([Bind(Include = "Event_ID,Event_Name,Event_StartTime,Event_EndTime,Event_Guest_Number,Event_Ticket_Price,Event_Location,Event_Description,Event_Type_ID")] Event_ event_)
 {
     if (ModelState.IsValid)
     {
         db.Entry(event_).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Event_Type_ID = new SelectList(db.Event_Type, "Event_Type_ID", "Event_Type_Name", event_.Event_Type_ID);
     return(View(event_));
 }
 public ActionResult Edit([Bind(Include = "Vol_ID,Vol_Name,Vol_Surname,Vol_Email,Vol_ContactNumber,Vol_Address,Vol_Emergency_ContactName,Vol_Emergency_ContactNumber,Title_ID")] Volunteer volunteer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volunteer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Title_ID = new SelectList(db.Titles, "Title_ID", "Title_Description", volunteer.Title_ID);
     return(View(volunteer));
 }
Beispiel #12
0
 public ActionResult Edit([Bind(Include = "Adopter_ID,Adopter_Name,Adopter_Surname,Adopter_Email,Title_ID,Adopter_Address,Adopter_PostalAddress,Adopter_HomeNumber,Adopter_WorkNumber,Adopter_CellNumber,Adopter_CarRegistartion_Number,Adopter_Employer,Adopter_Status_ID,Amount_of_Family_Memebers,No_of_Children,Age_of_Children,Property_Securely_Closed,Properyty_Include_Pool,Pool_Secured,Animal_Shelter_Available,Sick_Animal,Sick_Animal_Diagnosis,Animal_Sleep_Location,Given_Animal_Away,HomeCheck_Suburb,Type_of_House,Adopted_Before,Complex_or_Flat,Animal_Allowed,Animal_Captivity,Animal_Vaccines_Updated")] Adopter adopter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(adopter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Title_ID          = new SelectList(db.Titles, "Title_ID", "Title_Description", adopter.Title_ID);
     ViewBag.Adopter_Status_ID = new SelectList(db.Adopter_Status, "Adopter_Status_ID", "Adopter_Status_Name", adopter.Adopter_Status_ID);
     return(View(adopter));
 }
 public ActionResult Edit([Bind(Include = "Vol_Hours_ID,Vol_workDate,Vol_Start_Time,Vol_End_Time,Vol_ID,Vol_WorkType_ID")] Volunteer_Hours volunteer_Hours)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volunteer_Hours).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Vol_ID          = new SelectList(db.Volunteers, "Vol_ID", "Vol_Name", volunteer_Hours.Vol_ID);
     ViewBag.Vol_WorkType_ID = new SelectList(db.Volunteer_Work_Type, "Vol_WorkType_ID", "Vol_WorkType_Name", volunteer_Hours.Vol_WorkType_ID);
     return(View(volunteer_Hours));
 }
 public ActionResult Edit([Bind(Include = "Treat_ID,Animal_ID,Treat_StartDate,Treat_EndDate,Treat_Quantity,Treat_Regularity,Treat_Name,Treat_cost,Comment,Id")] Animal_Treatment animal_Treatment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(animal_Treatment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Animal_ID = new SelectList(db.Animals, "Animal_ID", "Animal_Image", animal_Treatment.Animal_ID);
     ViewBag.Id        = new SelectList(db.Mecidal_Card, "Id", "Diagnosis_Details", animal_Treatment.Id);
     return(View(animal_Treatment));
 }
 public ActionResult Edit([Bind(Include = "Customer_Event_ID,Customer_Event_Name,Customer_Event_Surname,Customer_Event_Email,Number_of_tickects,TicketFee_Date,TicketFee_Total,Event_ID,Payment_Type_ID")] Customer_Event customer_Event)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer_Event).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Event_ID        = new SelectList(db.Event_, "Event_ID", "Event_Name", customer_Event.Event_ID);
     ViewBag.Payment_Type_ID = new SelectList(db.Payment_Type, "Payment_Type_ID", "Payment_Type_Name", customer_Event.Payment_Type_ID);
     return(View(customer_Event));
 }
 public ActionResult Edit([Bind(Include = "Id,Animal_ID,Vet_Appointment_ID,Diagnosis_Details,Arrival_from_Vet,Next_Appointment_Date_,MedicalCard,Animal_Treatment")] Mecidal_Card mecidal_Card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mecidal_Card).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Animal_ID          = new SelectList(db.Animals, "Animal_ID", "Animal_Image", mecidal_Card.Animal_ID);
     ViewBag.Vet_Appointment_ID = new SelectList(db.Vet_Appointment, "Vet_Appointment_ID", "Vet_Appointment_ID", mecidal_Card.Vet_Appointment_ID);
     return(View(mecidal_Card));
 }
Beispiel #17
0
 public ActionResult Edit([Bind(Include = "Animal_Kennel_History_ID,Animal_ID,Kennel_ID")] Animal_Kennel_History animal_Kennel_History)
 {
     if (ModelState.IsValid)
     {
         db.Entry(animal_Kennel_History).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Animal_ID = new SelectList(db.Animals, "Animal_ID", "Animal_Name", animal_Kennel_History.Animal_ID);
     ViewBag.Kennel_ID = new SelectList(db.Kennels, "Kennel_ID", "Kennel_Name", animal_Kennel_History.Kennel_ID);
     return(View(animal_Kennel_History));
 }
 public ActionResult MaintainAnimal(Animal animal, Microchip micro, HttpPostedFileBase animalPicture, string button)
 {
     if (button == "Save")
     {
         try
         {
             Animal searchanimal = db.Animals.Find(animal.Animal_ID);
             if (searchanimal == null)
             {
                 return(HttpNotFound());
             }
             if (animalPicture != null)
             {
                 //this is where we convert the contract to add to the database
                 byte[] bytes;
                 using (BinaryReader br = new BinaryReader(animalPicture.InputStream))
                 {
                     bytes = br.ReadBytes(animalPicture.ContentLength);
                 }
                 animal.Animal_Image_Name = Path.GetFileName(animalPicture.FileName);
                 animal.Animal_Image_Type = animalPicture.ContentType;
                 animal.Animal_Image      = bytes;
             }
             db.Entry(searchanimal).CurrentValues.SetValues(animal);
             db.SaveChanges();
             TempData["SuccessMessage"] = "Successfully";
         }
         catch (Exception e)
         {
             ViewBag.err = e.Message;
             return(RedirectToAction("MaintainDonationType", "Donations"));
         }
     }
     else if (button == "Cancel")
     {
         TempData["SuccessMessage"] = "Successfully";
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Beispiel #19
0
        public ActionResult Edit([Bind(Include = "Relative_ID,Relative_Name,Relative_Surname,Relative_Email,Relative_Address,Relative_PostalAddress,Relative_Home_Tel,Relative_Work_Tel,Relative_Cell,Relationship,Adopter_ID")] Adopter_Relative adopter_Relative)
        {
            if (ModelState.IsValid)
            {
                db.Entry(adopter_Relative).State = EntityState.Modified;
                db.SaveChanges();

                //TempData["AdopterRelativeMessage"] = "Adopter Relative Successfully Created";
                return(RedirectToAction("Index"));
            }
            ViewBag.Adopter_ID = new SelectList(db.Adopters, "Adopter_ID", "Adopter_Name", adopter_Relative.Adopter_ID);
            return(View(adopter_Relative));
        }
 public ActionResult Edit([Bind(Include = "Vet_Appoint_Line_ID,Vet_ID,AppointmentDate,Description,Animal_ID,VetAppReasonsID")] Vet_Appointment_Master vet_Appointment_Master)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vet_Appointment_Master).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Animal_ID       = new SelectList(db.Animals, "Animal_ID", "Animal_Name", vet_Appointment_Master.Animal_ID);
     ViewBag.Vet_ID          = new SelectList(db.Veterinarians, "Vet_ID", "Vet_Name", vet_Appointment_Master.Vet_ID);
     ViewBag.VetAppReasonsID = new SelectList(db.VetAppReasons, "VetAppReasonsID", "Reason", vet_Appointment_Master.VetAppReasonsID);
     return(View(vet_Appointment_Master));
 }
        public ActionResult Checkin(int?id)
        {
            id++;
            DateTime  datenow = DateTime.Now;
            TimeSheet time    = new TimeSheet();

            time.Emp_ID   = flex.employee.Emp_ID;
            time.Check_in = datenow;

            db.TimeSheets.Add(time);
            db.SaveChanges();
            var emp    = db.Employees.Where(z => z.Emp_ID == flex.employee.Emp_ID).FirstOrDefault();
            var empold = db.Employees.Where(z => z.Emp_ID == flex.employee.Emp_ID).FirstOrDefault();

            if (emp == null)
            {
                ViewBag.err = "Employee is not found";
                return(View());
            }
            empold.Employee_Status_ID = 1;
            db.Entry(emp).CurrentValues.SetValues(empold);
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Edit([Bind(Include = "Vet_ID,Vet_Name,Vet_Emial,Vet_Tel,Vet_Address")] Veterinarian veterinarian)
        {
            if (ModelState.IsValid)
            {
                if (db.Veterinarians.Any(p => p.Vet_Name == veterinarian.Vet_Name)) //duplicate data
                {
                    ViewBag.Message = "Vet already exists";
                    /*ModelState.AddModelError("txtName", "Vet Name already exists.")*/
                }

                else
                {
                    db.Entry(veterinarian).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(veterinarian));
        }
        public ActionResult AddEmployee(int?Title, int?EmployeeType, Employee emp, User_ user, int?[] Role, string Gender, HttpPostedFileBase Contract)
        {
            Employee saveEmp = new Employee();

            try
            {
                if (Title == null || EmployeeType == null || emp == null)

                {
                    TempData["EditMessage"] = "Please Complete all the relevant information";
                    return(View("AddEmployee", innovation));
                }

                saveEmp = emp;
                //saveEmp.Emp_Gender = Gender;
                saveEmp.Title_ID    = Title;
                saveEmp.Emp_Type_ID = EmployeeType;

                //this is where we convert the contract to add to the database
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(Contract.InputStream))
                {
                    bytes = br.ReadBytes(Contract.ContentLength);
                }
                saveEmp.Emp_Contract_Name = Path.GetFileName(Contract.FileName);
                saveEmp.Emp_Contract_Type = Contract.ContentType;
                saveEmp.Emp_Contract      = bytes;

                db.Employees.Add(saveEmp);
                db.SaveChanges();
                //Now we have to store the user
                //first look for the employee that we just added
                Employee searchemp = db.Employees.Where(z => z.Title_ID == saveEmp.Title_ID && z.Emp_Type_ID == saveEmp.Emp_Type_ID && z.Emp_Name == saveEmp.Emp_Name && z.Emp_Email == saveEmp.Emp_Email && z.Emp_Surname == saveEmp.Emp_Surname && z.Emp_IDNumber == saveEmp.Emp_IDNumber).FirstOrDefault();
                Employee old       = db.Employees.Where(z => z.Title_ID == saveEmp.Title_ID && z.Emp_Type_ID == saveEmp.Emp_Type_ID && z.Emp_Name == saveEmp.Emp_Name && z.Emp_Email == saveEmp.Emp_Email && z.Emp_Surname == saveEmp.Emp_Surname && z.Emp_IDNumber == saveEmp.Emp_IDNumber).FirstOrDefault();
                //then we add the employee id to the user that we created at the top
                if (searchemp == null)
                {
                    TempData["SuccessMessage"] = "Successfully added the employee";
                    return(View("AddEmployee", innovation));
                }
                if (user == null || Role == null)
                {
                    TempData["SuccessMessage"] = "Succesfully added the employee";
                    return(View("AddEmployee", innovation));
                }
                user.Emp_ID = searchemp.Emp_ID;
                TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
                string UserUniqueKey       = (user.Username + key);
                Session["UserUniqueKey"] = UserUniqueKey;
                var setupInfo = tfa.GenerateSetupCode("Wollies Shelter", user.Username, UserUniqueKey, 300, 300);
                searchemp.BarcodeImageUrl = setupInfo.QrCodeSetupImageUrl;
                ViewBag.Qr = setupInfo.QrCodeSetupImageUrl;
                db.Entry(old).CurrentValues.SetValues(searchemp);
                db.SaveChanges();
                //var md5 = new MD5CryptoServiceProvider();
                //var pass = md5.ComputeHash(Convert.FromBase64String(user.Password));
                //user.Password = pass;
                //we store the info

                db.User_.Add(user);
                db.SaveChanges();
                //we store the User acces that is needed
                User_ searchuser = db.User_.Where(z => z.Emp_ID == searchemp.Emp_ID).FirstOrDefault();

                if (searchuser == null)
                {
                    return(View("AddEmployee", innovation));
                }

                foreach (var item in Role)
                {
                    UserRole userRole = new UserRole();
                    userRole.UserID  = searchuser.UserID;
                    userRole.Role_ID = item;
                    db.UserRoles.Add(userRole);
                    db.SaveChanges();
                    TempData["SuccessMessage"] = "Succesfully added the User";
                }
                user = searchuser;

                TempData["SuccessMessage"] = "Succesfully added the User";
                return(View("BarCodeGenerated", user));
            }


            catch (Exception e)
            {
                TempData["EditMessage"] = e.Message;
                return(RedirectToAction("AddEmployee"));
            }
        }