public async Task <IActionResult> DeleteConfirmed(int id)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Applicants");

            var applicant = await _context.Applicants
                            .Include(a => a.RetrainingProgram)
                            .FirstOrDefaultAsync(m => m.ID == id);

            try
            {
                _context.Applicants.Remove(applicant);
                await _context.SaveChangesAsync();

                return(Redirect(ViewData["returnURL"].ToString()));
            }

            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("Cannot delete seeded data"))
                {
                    ModelState.AddModelError("", "Unable to delete. Remember, you cannot delete originally seeded data.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            return(View(applicant));
        }
예제 #2
0
        // GET: Skills/Create
        public IActionResult Create()
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Skills");

            return(View());
        }
예제 #3
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Employees");

            try
            {
                var employee = await _context.Employees.FindAsync(id);

                _context.Employees.Remove(employee);
                await _context.SaveChangesAsync();

                return(Redirect(ViewData["returnURL"].ToString()));
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("FOREIGN KEY constraint failed"))
                {
                    ModelState.AddModelError("", "Unable to Delete Employee. You cannot delete an employees assigned to a team.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
        // GET: Applicants/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Applicants");

            var applicant = await _context.Applicants
                            .Include(a => a.RetrainingProgram)
                            .Include(a => a.ApplicantDocuments)
                            .Include(p => p.ApplicantPhoto).ThenInclude(p => p.PhotoContentFull)
                            .Include(a => a.Applications).ThenInclude(a => a.Posting)
                            .ThenInclude(a => a.Position)//We need this for the summary property in Posting
                            .FirstOrDefaultAsync(m => m.ID == id);

            if (applicant == null)
            {
                return(NotFound());
            }

            return(View(applicant));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Patients");

            var patient = await _context.Patients
                          .Include(p => p.Doctor)
                          .Include(p => p.MedicalTrial)
                          .Include(p => p.PatientConditions).ThenInclude(p => p.Condition)
                          .Include(p => p.PatientPhoto).ThenInclude(p => p.PhotoContentFull)
                          .AsNoTracking()
                          .SingleOrDefaultAsync(p => p.ID == id);

            if (patient == null)
            {
                return(NotFound());
            }
            PopulateAssignedConditionData(patient);
            PopulateDropDownLists(patient);
            return(View(patient));
        }
예제 #6
0
        public async Task <IActionResult> RemoveConfirmed(int id)
        {
            var appointment = await _context.Appointments
                              .Include(a => a.ApptReason)
                              .Include(a => a.Patient)
                              .FirstOrDefaultAsync(m => m.ID == id);

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "PatientAppt");

            try
            {
                _context.Appointments.Remove(appointment);
                await _context.SaveChangesAsync();

                //return RedirectToAction("Index", new { appointment.PatientID });
                return(Redirect(ViewData["returnURL"].ToString()));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(appointment));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("ID,OrgName,FirstName,LastName,MiddleName,Position,AddressLineOne,AddressLineTwo,ApartmentNumber,City,Province,Country,Phone,Email")] Customer customer, int projectTrue)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Customers");
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(customer);
                    await _context.SaveChangesAsync();

                    //return RedirectToAction(nameof(Index));

                    if (projectTrue == 1)
                    {
                        return(RedirectToAction(actionName: "Create", controllerName: "Projects", new { customerID = customer.ID }));
                    }

                    return(RedirectToAction("Details", new { customer.ID }));
                }
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Customers.Email"))
                {
                    ModelState.AddModelError("Email", "Unable to save changes.You cannot have same email address as another employee .");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            return(View(customer));
        }
예제 #8
0
        // GET: Contacts/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Contacts");

            ////Get the URL of the page that send us here
            //if (String.IsNullOrEmpty(returnURL))
            //{
            //    returnURL = Request.Headers["Referer"].ToString();
            //}
            //ViewData["returnURL"] = returnURL;

            if (id == null)
            {
                return(NotFound());
            }

            var contact = await _context.Contacts
                          .Include(c => c.Company)
                          .FirstOrDefaultAsync(m => m.ContactID == id);

            if (contact == null)
            {
                return(NotFound());
            }

            return(View(contact));
        }
예제 #9
0
        public async Task <IActionResult> Edit(int?id)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Contacts");

            ////Get the URL of the page that send us here
            //if (String.IsNullOrEmpty(returnURL))
            //{
            //    returnURL = Request.Headers["Referer"].ToString();
            //}
            //ViewData["returnURL"] = returnURL;

            if (id == null)
            {
                return(NotFound());
            }

            var contact = await _context.Contacts
                          .Include(c => c.ContactCategories).ThenInclude(c => c.Categories)
                          .SingleOrDefaultAsync(c => c.ContactID == id);


            if (contact == null)
            {
                return(NotFound());
            }
            ViewData["CompanyID"] = new SelectList(_context.Companies, "CompanyID", "Name", contact.CompanyID);
            PopulateAssignedCategoryData(contact);
            return(View(contact));
        }
        // GET: Applicants/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Applicants");

            var applicant = await _context.Applicants
                            .Include(a => a.RetrainingProgram)
                            .Include(p => p.ApplicantPhoto).ThenInclude(p => p.PhotoContentFull)
                            .Include(a => a.ApplicantDocuments)
                            .Include(a => a.ApplicantSkills)
                            .AsNoTracking()
                            .SingleOrDefaultAsync(a => a.ID == id);

            if (applicant == null)
            {
                return(NotFound());
            }

            //Staff can only edit records they created
            if (User.IsInRole("Staff") && (User.Identity.Name != applicant.CreatedBy))
            {
                ModelState.AddModelError("", "NOTE: You cannot save changes to this record since you did not enter it into the system.");
            }

            PopulateAssignedSkillData(applicant);
            PopulateDropDownLists(applicant);
            return(View(applicant));
        }
예제 #11
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Customers");

            var customer = await _context.Customers.FindAsync(id);

            try
            {
                _context.Customers.Remove(customer);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(Redirect(ViewData["returnURL"].ToString()));
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("FOREIGN KEY constraint failed"))
                {
                    ModelState.AddModelError("", "Unable to Delete Customer. You cannot delete a Customer that has ongoing projects.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            return(View(customer));
        }
예제 #12
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Projects");

            var project = await _context.Projects
                          .Include(p => p.Bids)
                          .FirstOrDefaultAsync(m => m.ID == id);

            try
            {
                _context.Projects.Remove(project);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(Redirect(ViewData["returnURL"].ToString()));
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("FOREIGN KEY constraint failed"))
                {
                    ModelState.AddModelError("", "Unable to Delete Project. You cannot delete a Project that has Bids Designed.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            return(View(project));
        }
예제 #13
0
        public IActionResult Create(string CType)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Companies");
            Company company = new Company();

            ////Get the URL of the page that send us here
            //if (String.IsNullOrEmpty(returnURL))
            //{
            //    returnURL = Request.Headers["Referer"].ToString();
            //}

            //ViewData["returnURL"] = returnURL;
            ViewData["CType"]              = CType;
            ViewData["BillingCountryID"]   = new SelectList(_context.Countries, "CountryID", "CountryName");
            ViewData["BillingProvinceID"]  = GetProvincesSelectList();
            ViewData["BillingTermID"]      = new SelectList(_context.BillingTerms.OrderBy(t => t.Order), "BillingTermID", "Terms");
            ViewData["CurrencyID"]         = new SelectList(_context.Currencies.OrderBy(t => t.Order), "CurrencyID", "CurrencyName");
            ViewData["ShippingCountryID"]  = new SelectList(_context.Countries, "CountryID", "CountryName");
            ViewData["ShippingProvinceID"] = GetProvincesSelectList();
            ViewData["CustomerTypeID"]     = new SelectList(_context.CustomerTypes.OrderBy(t => t.Order), "CustomerTypeID", "Type");
            ViewData["ContractorTypeID"]   = new SelectList(_context.ContractorTypes.OrderBy(t => t.Order), "ContractorTypeID", "Type");
            ViewData["VendorTypeID"]       = new SelectList(_context.VendorTypes.OrderBy(t => t.Order), "VendorTypeID", "Type");

            return(View());
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Postings");

            var posting = await _context.Postings
                          .Include(p => p.PostingDocuments)
                          .SingleOrDefaultAsync(p => p.ID == id);

            if (posting == null)
            {
                return(NotFound());
            }

            //Staff can only edit records they created
            if (User.IsInRole("Staff") && (User.Identity.Name != posting.CreatedBy))
            {
                ModelState.AddModelError("", "NOTE: You cannot save changes to this record since you did not enter it into the system.");
            }

            PopulateDropDownLists(posting);
            return(View(posting));
        }
예제 #15
0
        public async Task <IActionResult> Create([Bind("ID,Name,LabourCostPerHr,LabourPricePerHr")] Role role, int employeeTrue)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Roles");

            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(role);
                    await _context.SaveChangesAsync();

                    //return RedirectToAction(nameof(Index));
                    if (employeeTrue == 1)
                    {
                        return(RedirectToAction(actionName: "Create", controllerName: "Employees", new { roleID = role.ID }));
                    }

                    return(RedirectToAction("Details", new { role.ID }));
                }
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Roles.Name"))
                {
                    ModelState.AddModelError("Name", "Unable to save changes.You cannot have duplicate Role Names.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            return(View(role));
        }
예제 #16
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Skills");

            var skill = await _context.Skills.FindAsync(id);

            try
            {
                _context.Skills.Remove(skill);
                await _context.SaveChangesAsync();

                return(Redirect(ViewData["returnURL"].ToString()));
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("FOREIGN KEY constraint failed"))
                {
                    ModelState.AddModelError("", "Unable to delete Skill. Remember, you cannot delete a Skill noted for any Applicants.");
                }
                else if (dex.GetBaseException().Message.Contains("Cannot delete seeded data"))
                {
                    ModelState.AddModelError("", "Unable to delete. Remember, you cannot delete originally seeded data.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            return(View(skill));
        }
예제 #17
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,MiddleName,AddressLineOne,AddressLineTwo,ApartmentNumber,City,Province,Country,Phone,Email,RoleID,IsUser")] Employee employee, int fromRoleID)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Employees");

            if (fromRoleID != 0)
            {
                //set the tempdata again for post back after error
                TempData["RoleID"] = fromRoleID;

                employee.RoleID = fromRoleID;
            }
            else
            {
                //set the tempdata again for post back after error
                TempData["RoleID"] = 0;
            }



            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(employee);

                    if (employee.IsUser)
                    {
                        try
                        {
                            employee.UserName = employee.SetUserName;
                            UpdateUserAccount(employee);
                        }
                        catch
                        {
                            ModelState.AddModelError("", "Employee User Account Could not be created");
                        }
                    }

                    await _context.SaveChangesAsync();

                    //return RedirectToAction(nameof(Index));

                    return(RedirectToAction("Details", new { employee.ID }));
                }
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Employees.Email"))
                {
                    ModelState.AddModelError("Email", "Unable to save changes.You cannot have same email address as another employee .");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            PopulateDropDownLists(employee);
            return(View(employee));
        }
        public IActionResult Create()
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Postings");

            PopulateDropDownLists();
            return(View());
        }
예제 #19
0
        public async Task <IActionResult> Edit(int id, string[] selectedOptions)
        {
            var positionToUpdate = await _context.Positions
                                   .Include(p => p.PositionSkills).ThenInclude(p => p.Skill)
                                   .SingleOrDefaultAsync(p => p.ID == id);

            //Check that you got it or exit with a not found error
            if (positionToUpdate == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Positions");

            UpdatePositionSkills(selectedOptions, positionToUpdate);

            if (await TryUpdateModelAsync <Position>(positionToUpdate, "",
                                                     d => d.Name, d => d.Description, d => d.Salary, d => d.OccupationID))
            {
                try
                {
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Details", new { positionToUpdate.ID }));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PositionExists(positionToUpdate.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator.");
                }
                catch (DbUpdateException dex)
                {
                    if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed"))
                    {
                        ModelState.AddModelError("Name", "Unable to save changes. Remember, you cannot have duplicate position names.");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                    }
                }
            }
            PopulateAssignedSkillData(positionToUpdate);
            PopulateDropDownLists(positionToUpdate);
            return(View(positionToUpdate));
        }
예제 #20
0
        public async Task <IActionResult> Edit(int id, [Bind("ContactID,FirstName,LastName,JobTitle,CellPhone,WorkPhone,Email,Active,Notes,CompanyID")] Contact contact,
                                               string[] selectedOptions)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Contacts");

            //ViewData["returnURL"] = returnURL;
            var contactToUpdate = await _context.Contacts
                                  .Include(c => c.ContactCategories).ThenInclude(c => c.Categories)
                                  .SingleOrDefaultAsync(c => c.ContactID == id);

            if (id != contact.ContactID)
            {
                return(NotFound());
            }

            UpdateContactCategory(selectedOptions, contactToUpdate); // Updateing categories

            if (await TryUpdateModelAsync <Contact>(contactToUpdate, "", c => c.FirstName, c => c.LastName, c => c.JobTitle,
                                                    c => c.CellPhone, c => c.WorkPhone, c => c.Email, c => c.Active, c => c.Notes, c => c.CompanyID))
            {
                try
                {
                    _context.Update(contactToUpdate);
                    await _context.SaveChangesAsync();
                }
                catch (RetryLimitExceededException)
                {
                    ModelState.AddModelError("", "Ineffectual save changes after multiple attempts. Try again. If the problem persists, please contact your system administrator.");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.ContactID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //if(String.IsNullOrEmpty(returnURL))
                //{
                //    return RedirectToAction(nameof(Index), new { CType = CType });
                //}
                //else
                //{
                //    return Redirect(returnURL);
                //}
                return(Redirect(ViewData["returnURL"].ToString()));
            }

            ViewData["CompanyID"] = new SelectList(_context.Companies, "CompanyID", "Name", contact.CompanyID);
            PopulateAssignedCategoryData(contactToUpdate);
            return(View(contactToUpdate));
        }
예제 #21
0
        // GET: Roles/Create
        public IActionResult Create()
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Roles");
            if (!TempData.ContainsKey("fromProject"))
            {
                TempData["fromProject"] = "False";
            }

            return(View());
        }
예제 #22
0
        public IActionResult Create()
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Positions");

            Position position = new Position();

            PopulateAssignedSkillData(position);
            PopulateDropDownLists();
            return(View());
        }
예제 #23
0
        public IActionResult Create()
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Employees");

            ViewData["EmployeeCountryID"]  = GetCountriesSelectList();
            ViewData["EmployeeProvinceID"] = GetProvincesSelectList();
            ViewData["EmploymentTypeID"]   = GetEmploymentTypesSelectList();
            ViewData["JobPositionID"]      = GetPositionsSelectList();
            return(View());
        }
예제 #24
0
        public IActionResult Create()
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Patients");

            //Add all (unchecked) Conditions to ViewBag
            var patient = new Patient();

            PopulateAssignedConditionData(patient);
            PopulateDropDownLists();
            return(View());
        }
예제 #25
0
        public async Task <IActionResult> Create([Bind("ID,OHIP,FirstName,MiddleName,LastName,DOB,ExpYrVisits,Phone,eMail,MedicalTrialID,DoctorID")] Patient patient,
                                                 string[] selectedOptions, IFormFile thePicture)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Patients");

            try
            {
                //Add the selected conditions
                if (selectedOptions != null)
                {
                    foreach (var condition in selectedOptions)
                    {
                        var conditionToAdd = new PatientCondition {
                            PatientID = patient.ID, ConditionID = int.Parse(condition)
                        };
                        patient.PatientConditions.Add(conditionToAdd);
                    }
                }

                if (ModelState.IsValid)
                {
                    await AddPicture(patient, thePicture);

                    _context.Add(patient);
                    await _context.SaveChangesAsync();

                    //Send on to add appointments
                    return(RedirectToAction("Index", "PatientAppt", new { PatientID = patient.ID }));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator.");
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Patients.OHIP"))
                {
                    ModelState.AddModelError("OHIP", "Unable to save changes. Remember, you cannot have duplicate OHIP numbers.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            //Validaiton Error so give the user another chance.
            PopulateAssignedConditionData(patient);
            PopulateDropDownLists(patient);
            return(View(patient));
        }
예제 #26
0
        // GET: Companies/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Companies");

            if (id == null)
            {
                return(NotFound());
            }

            //Get the URL of the page that send us here
            //if (String.IsNullOrEmpty(returnURL))
            //{
            //    returnURL = Request.Headers["Referer"].ToString();
            //}
            //ViewData["returnURL"] = returnURL;

            var company = await _context.Companies
                          .Include(c => c.BillingCountry)
                          .Include(c => c.BillingProvince)
                          .Include(c => c.BillingTerm)
                          .Include(c => c.Currency)
                          .Include(c => c.ShippingCountry)
                          .Include(c => c.ShippingProvince)
                          .FirstOrDefaultAsync(m => m.CompanyID == id);

            if (company == null)
            {
                return(NotFound());
            }

            GetTypesIn(id, out var customerTypes, out var contractorTypes, out var vendorTypes);
            var dict = new Dictionary <string, List <CompanyTypesDto> >();

            if (customerTypes.Count > 0)
            {
                dict.Add("customer", customerTypes);
            }
            if (contractorTypes.Count > 0)
            {
                dict.Add("contractor", contractorTypes);
            }
            if (vendorTypes.Count > 0)
            {
                dict.Add("vendor", vendorTypes);
            }
            ViewData["CompanyTypes"] = dict;

            return(View(company));
        }
예제 #27
0
        public async Task <IActionResult> Create([Bind("ID,Name,SiteAddressLineOne,SiteAddressLineTwo,City,Province,Country,CustomerID")] Project project, int bidTrue, int fromCustomerID)
        {
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Projects");

            if (fromCustomerID != 0)
            {
                //set the tempdata again for post back after error
                TempData["CustomerID"] = fromCustomerID;

                project.CustomerID = fromCustomerID;
            }
            else
            {
                //set the tempdata again for post back after error
                TempData["CustomerID"] = 0;
            }

            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(project);
                    await _context.SaveChangesAsync();

                    //return RedirectToAction(nameof(Index));

                    if (bidTrue == 1)
                    {
                        return(RedirectToAction(actionName: "Create", controllerName: "Bids", new { projectID = project.ID }));
                    }

                    return(RedirectToAction("Details", new { project.ID }));
                }
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Projects.Name"))
                {
                    ModelState.AddModelError("Name", "Unable to save changes.You cannot have duplicate Project Names.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            PopulateDropDownLists(project);
            return(View(project));
        }
        public async Task <IActionResult> Create([Bind("ID,FirstName,MiddleName,LastName,SIN,Phone,eMail,RetrainingProgramID")] Applicant applicant,
                                                 string[] selectedOptions, IFormFile thePicture, List <IFormFile> theFiles)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Applicants");

            try
            {
                //Add the selected skills
                if (selectedOptions != null)
                {
                    foreach (var skill in selectedOptions)
                    {
                        var skillToAdd = new ApplicantSkill {
                            ApplicantID = applicant.ID, SkillID = int.Parse(skill)
                        };
                        applicant.ApplicantSkills.Add(skillToAdd);
                    }
                }
                if (ModelState.IsValid)
                {
                    await AddPicture(applicant, thePicture);
                    await AddDocumentsAsync(applicant, theFiles);

                    _context.Add(applicant);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Details", new { applicant.ID }));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator.");
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed"))
                {
                    ModelState.AddModelError("", "Unable to save changes. Remember, you cannot have duplicate eMail addresses.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            PopulateDropDownLists(applicant);
            return(View(applicant));
        }
예제 #29
0
        // GET: Roles/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Roles");

            var role = await _context.Roles.FindAsync(id);

            if (role == null)
            {
                return(NotFound());
            }
            return(View(role));
        }
예제 #30
0
        public async Task <IActionResult> Update(int id)
        {
            var appointmentToUpdate = await _context.Appointments
                                      .Include(a => a.ApptReason)
                                      .Include(a => a.Patient)
                                      .FirstOrDefaultAsync(m => m.ID == id);

            //Check that you got it or exit with a not found error
            if (appointmentToUpdate == null)
            {
                return(NotFound());
            }

            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "PatientAppt");

            //Try updating it with the values posted
            if (await TryUpdateModelAsync <Appointment>(appointmentToUpdate, "",
                                                        p => p.Notes, p => p.appDate, p => p.extraFee, p => p.ApptReasonID))
            {
                try
                {
                    _context.Update(appointmentToUpdate);
                    await _context.SaveChangesAsync();

                    return(Redirect(ViewData["returnURL"].ToString()));
                }

                catch (DbUpdateConcurrencyException)
                {
                    if (!AppointmentExists(appointmentToUpdate.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (DbUpdateException)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }
            PopulateDropDownLists(appointmentToUpdate);
            return(View(appointmentToUpdate));
        }