Пример #1
0
        public async Task <IActionResult> Edit(int id, InquiryFormViewModel inquiryFormViewModel)
        {
            Clineitem ci = inquiryFormViewModel.Note;

            if (id != ci.ClineitemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ci);
                    TempData["Alert"] = "Saved Changes to Note";
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClineitemExists(ci.ClineitemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Edit", "ClientServices", new { id = ci.ClientServiceId }));
            }
            ViewData["ClientServiceId"] = new SelectList(_context.ClientServices, "ClientServiceId", "ClientServiceId", ci.ClientServiceId);
            ViewData["ZworkerId"]       = new SelectList(_context.Zworker.OrderBy(m => m.worker), "ZworkerId", "worker", ci.ZworkerId);
            ViewData["ZactionId"]       = new SelectList(_context.Zaction.OrderBy(m => m.action), "ZactionId", "action", ci.ZactionId);
            return(View(inquiryFormViewModel));
        }
Пример #2
0
        // GET: Clineitems/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var clineitem = await _context.Clineitems.FindAsync(id);

            if (clineitem == null)
            {
                return(NotFound());
            }
            ViewData["ClientServiceId"] = new SelectList(_context.ClientServices, "ClientServiceId", "ClientServiceId", clineitem.ClientServiceId);
            ViewData["ZworkerId"]       = new SelectList(_context.Zworker.OrderBy(m => m.worker), "ZworkerId", "worker", clineitem.ZworkerId);
            ViewData["ZactionId"]       = new SelectList(_context.Zaction.OrderBy(m => m.action), "ZactionId", "action", clineitem.ZactionId);

            InquiryFormViewModel inquiryFormViewModel = new InquiryFormViewModel();

            inquiryFormViewModel.Inquiry = await _context.ClientServices.FirstOrDefaultAsync(cs => cs.ClientServiceId == clineitem.ClientServiceId);

            inquiryFormViewModel.Note = clineitem;

            return(View(inquiryFormViewModel));
        }
        public async Task <IActionResult> Create(InquiryFormViewModel inquiryFormViewModel)
        {
            ClientService cs     = inquiryFormViewModel.Inquiry;
            Clineitem     ci     = inquiryFormViewModel.Note;
            ScaScreen     sca    = inquiryFormViewModel.ScaScreen;
            Client        client = inquiryFormViewModel.Client;

            if (ModelState.IsValid)
            {
                int clientId = (int)cs.ClientId;
                client.ClientId = clientId;
                _context.Update(client);
                await _context.SaveChangesAsync();

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

                ci.ClientServiceId = cs.ClientServiceId;
                _context.Add(ci);
                await _context.SaveChangesAsync();

                sca.ClientServiceId = cs.ClientServiceId;
                _context.Update(sca);
                await _context.SaveChangesAsync();

                TempData["Alert"] = "Created Inquiry";
                return(RedirectToAction("Edit", "ClientServices", new { id = cs.ClientServiceId }));
            }
            ViewData["ClientId"]            = new SelectList(_context.Clients.OrderBy(m => m.name), "ClientId", "name", cs.ClientId);
            ViewData["ServiceId"]           = new SelectList(_context.Services.OrderBy(m => m.service_desc), "ServiceId", "service_desc", cs.ServiceId);
            ViewData["ZcaresreasonId"]      = new SelectList(_context.Zcaresreason.OrderBy(m => m.caresreason), "ZcaresreasonId", "caresreason", cs.ZcaresreasonId);
            ViewData["ZhearaboutId"]        = new SelectList(_context.Zhearabout.OrderBy(m => m.hearabout), "ZhearaboutId", "hearabout", cs.ZhearaboutId);
            ViewData["ZinternalId"]         = new SelectList(_context.Zinternal.Where(m => m.active).OrderBy(m => m.internal_type), "ZinternalId", "internal_type", cs.ZinternalId);
            ViewData["ZinternalcategoryId"] = new SelectList(_context.Zinternalcategory.OrderBy(m => m.internalsubcat), "ZinternalcategoryId", "internalsubcat", cs.ZinternalcategoryId);
            ViewData["ZlocationId"]         = new SelectList(_context.Zlocation.OrderBy(m => m.location), "ZlocationId", "location", cs.ZlocationId);
            ViewData["ZopotherId"]          = new SelectList(_context.Zopother.OrderBy(m => m.opother), "ZopotherId", "opother", cs.ZopotherId);
            ViewData["ZplatformId"]         = new SelectList(_context.Zplatform.OrderBy(m => m.opplatform), "ZplatformId", "opplatform", cs.ZplatformId);
            ViewData["ZprogramsId"]         = new SelectList(_context.Zprograms.Where(m => m.active).OrderBy(m => m.program_desc), "ZprogramsId", "program_desc", cs.ZprogramsId);
            ViewData["ZreasonId"]           = new SelectList(_context.Zreason.Where(m => m.active).OrderBy(m => m.final_reason), "ZreasonId", "final_reason", cs.ZreasonId);
            ViewData["ZresourcereasonId"]   = new SelectList(_context.Zresourcereason.OrderBy(m => m.resourceresult), "ZresourcereasonId", "resourceresult", cs.ZresourcereasonId);
            ViewData["ZschoolId"]           = new SelectList(_context.Zschool.Where(m => m.active).OrderBy(m => m.displayname), "ZschoolId", "displayname", cs.ZschoolId);
            ViewData["ZsiteId"]             = new SelectList(_context.Zsite.Where(m => m.active).OrderBy(m => m.site), "ZsiteId", "site", cs.ZsiteId);
            ViewData["ZstatusId"]           = new SelectList(_context.Zstatus.Where(m => m.active).OrderBy(m => m.inq_status), "ZstatusId", "inq_status", cs.ZstatusId);
            ViewData["ZworkerId"]           = new SelectList(_context.Zworker.Where(m => m.active).OrderBy(m => m.worker), "ZworkerId", "worker", cs.ZworkerId);

            return(View(inquiryFormViewModel));
        }
        // GET: ClientServices/Create
        public async Task <IActionResult> Create(int clientid)
        {
            ViewData["ClientId"]            = new SelectList(_context.Clients.OrderBy(m => m.name), "ClientId", "name");
            ViewData["ServiceId"]           = new SelectList(_context.Services.Where(m => m.active).OrderBy(m => m.service_desc), "ServiceId", "service_desc");
            ViewData["ZcaresreasonId"]      = new SelectList(_context.Zcaresreason.OrderBy(m => m.caresreason), "ZcaresreasonId", "caresreason");
            ViewData["ZhearaboutId"]        = new SelectList(_context.Zhearabout.OrderBy(m => m.hearabout), "ZhearaboutId", "hearabout");
            ViewData["ZinternalId"]         = new SelectList(_context.Zinternal.Where(m => m.active).OrderBy(m => m.internal_type), "ZinternalId", "internal_type");
            ViewData["ZinternalcategoryId"] = new SelectList(_context.Zinternalcategory.OrderBy(m => m.internalsubcat), "ZinternalcategoryId", "internalsubcat");
            ViewData["ZlocationId"]         = new SelectList(_context.Zlocation.OrderBy(m => m.location), "ZlocationId", "location");
            ViewData["ZopotherId"]          = new SelectList(_context.Zopother.OrderBy(m => m.opother), "ZopotherId", "opother");
            ViewData["ZplatformId"]         = new SelectList(_context.Zplatform.OrderBy(m => m.opplatform), "ZplatformId", "opplatform");
            ViewData["ZprogramsId"]         = new SelectList(_context.Zprograms.Where(m => m.active).OrderBy(m => m.program_desc), "ZprogramsId", "program_desc");
            ViewData["ZreasonId"]           = new SelectList(_context.Zreason.Where(m => m.active).OrderBy(m => m.final_reason), "ZreasonId", "final_reason");
            ViewData["ZresourcereasonId"]   = new SelectList(_context.Zresourcereason.OrderBy(m => m.resourceresult), "ZresourcereasonId", "resourceresult");
            ViewData["ZschoolId"]           = new SelectList(_context.Zschool.Where(m => m.active).OrderBy(m => m.displayname), "ZschoolId", "displayname");
            ViewData["ZsiteId"]             = new SelectList(_context.Zsite.Where(m => m.active).OrderBy(m => m.site), "ZsiteId", "site");
            ViewData["ZstatusId"]           = new SelectList(_context.Zstatus.Where(m => m.active).OrderBy(m => m.inq_status), "ZstatusId", "inq_status");

            InquiryFormViewModel inquiryFormViewModel = new InquiryFormViewModel();

            inquiryFormViewModel.Client = await _context.Clients.FirstOrDefaultAsync(m => m.ClientId == clientid);

            inquiryFormViewModel.Inquiry = new ClientService {
                Client = inquiryFormViewModel.Client
            };
            inquiryFormViewModel.Inquiry.ClientId = inquiryFormViewModel.Client.ClientId;
            inquiryFormViewModel.Inquiry.recdate  = DateTime.Now;
            inquiryFormViewModel.Note             = new Clineitem {
                ClientServiceId = inquiryFormViewModel.Inquiry.ClientServiceId
            };
            inquiryFormViewModel.Note.ldate = DateTime.Now;
            inquiryFormViewModel.Notes      = await _context.Clineitems.Where(ci => ci.ClientServiceId == inquiryFormViewModel.Inquiry.ClientServiceId).OrderByDescending(ci => ci.ldate).ToListAsync();

            inquiryFormViewModel.ScaScreen = new ScaScreen {
                ClientService = inquiryFormViewModel.Inquiry
            };
            inquiryFormViewModel.ScaScreen.ClientServiceId = inquiryFormViewModel.Inquiry.ClientServiceId;

            ViewData["ZcountyId"]    = new SelectList(_context.Zcounty.OrderBy(m => m.county), "ZcountyId", "county", inquiryFormViewModel.Client.ZcountyId);
            ViewData["ZraceId"]      = new SelectList(_context.Zrace.OrderBy(m => m.race), "ZraceId", "race", inquiryFormViewModel.Client.ZraceId);
            ViewData["ZinsuranceId"] = new SelectList(_context.Zinsurance.Where(m => m.active).OrderBy(m => m.insurance), "ZinsuranceId", "insurance", inquiryFormViewModel.Client.ZinsuranceId);
            ViewData["ZactionId"]    = new SelectList(_context.Zaction.OrderBy(m => m.action), "ZactionId", "action", inquiryFormViewModel.Note.ZactionId);
            ViewData["ZworkerId"]    = new SelectList(_context.Zworker.Where(m => m.active).OrderBy(m => m.worker), "ZworkerId", "worker", inquiryFormViewModel.Note.ZworkerId);

            return(View(inquiryFormViewModel));
        }
        public async Task <IActionResult> Create(InquiryFormViewModel inquiryFormViewModel)
        {
            ClientService cs = inquiryFormViewModel.Inquiry;
            Clineitem     ci = inquiryFormViewModel.Note;

            if (ModelState.IsValid)
            {
                ci.ClientServiceId = cs.ClientServiceId;
                _context.Add(ci);
                await _context.SaveChangesAsync();

                TempData["Alert"] = "Created Note";
                return(RedirectToAction("Details", "ClientServices", new { id = cs.ClientServiceId }));
            }
            ViewData["ClientServiceId"] = new SelectList(_context.ClientServices, "ClientServiceId", "ClientServiceId", ci.ClientServiceId);
            ViewData["ZworkerId"]       = new SelectList(_context.Zworker.OrderBy(m => m.worker), "ZworkerId", "worker", ci.ZworkerId);
            return(View(inquiryFormViewModel));
        }
        // GET: Clineitems/Create
        public async Task <IActionResult> Create(int csid)
        {
            ViewData["ClientServiceId"] = new SelectList(_context.ClientServices, "ClientServiceId", "ClientServiceId");
            ViewData["ZworkerId"]       = new SelectList(_context.Zworker.OrderBy(m => m.worker), "ZworkerId", "worker");

            InquiryFormViewModel inquiryFormViewModel = new InquiryFormViewModel();

            inquiryFormViewModel.Inquiry = await _context.ClientServices.FirstOrDefaultAsync(cs => cs.ClientServiceId == csid);

            inquiryFormViewModel.Client = await _context.Clients.FirstOrDefaultAsync(c => c.ClientId == inquiryFormViewModel.Inquiry.ClientId);

            inquiryFormViewModel.Note = new Clineitem {
                ClientServiceId = inquiryFormViewModel.Inquiry.ClientServiceId
            };
            inquiryFormViewModel.Note.ldate = DateTime.Now;
            inquiryFormViewModel.Notes      = await _context.Clineitems.Where(ci => ci.ClientServiceId == inquiryFormViewModel.Inquiry.ClientServiceId).OrderByDescending(ci => ci.ldate).ToListAsync();

            return(View(inquiryFormViewModel));
        }
        public async Task <IActionResult> Edit(int id, InquiryFormViewModel inquiryFormViewModel)
        {
            ClientService cs     = inquiryFormViewModel.Inquiry;
            ScaScreen     sca    = inquiryFormViewModel.ScaScreen;
            Client        client = inquiryFormViewModel.Client;

            if (id != cs.ClientServiceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    client.ClientId = (int)cs.ClientId;
                    _context.Update(client);
                    await _context.SaveChangesAsync();

                    _context.Update(cs);
                    sca.ClientServiceId = cs.ClientServiceId;
                    await _context.SaveChangesAsync();

                    _context.Update(sca);
                    TempData["Alert"] = "Saved Changes to Inquiry";
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientServiceExists(cs.ClientServiceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "ClientServices", new { id = cs.ClientServiceId }));
            }
            ViewData["ClientId"]            = new SelectList(_context.Clients.OrderBy(m => m.name), "ClientId", "name", cs.ClientId);
            ViewData["ServiceId"]           = new SelectList(_context.Services.OrderBy(m => m.service_desc), "ServiceId", "service_desc", cs.ServiceId);
            ViewData["ZcaresreasonId"]      = new SelectList(_context.Zcaresreason.OrderBy(m => m.caresreason), "ZcaresreasonId", "caresreason", cs.ZcaresreasonId);
            ViewData["ZhearaboutId"]        = new SelectList(_context.Zhearabout.OrderBy(m => m.hearabout), "ZhearaboutId", "hearabout", cs.ZhearaboutId);
            ViewData["ZinternalId"]         = new SelectList(_context.Zinternal.Where(m => m.active).OrderBy(m => m.internal_type), "ZinternalId", "internal_type", cs.ZinternalId);
            ViewData["ZinternalcategoryId"] = new SelectList(_context.Zinternalcategory.OrderBy(m => m.internalsubcat), "ZinternalcategoryId", "internalsubcat", cs.ZinternalcategoryId);
            ViewData["ZlocationId"]         = new SelectList(_context.Zlocation.OrderBy(m => m.location), "ZlocationId", "location", cs.ZlocationId);
            ViewData["ZopotherId"]          = new SelectList(_context.Zopother.OrderBy(m => m.opother), "ZopotherId", "opother", cs.ZopotherId);
            ViewData["ZplatformId"]         = new SelectList(_context.Zplatform.OrderBy(m => m.opplatform), "ZplatformId", "opplatform", cs.ZplatformId);
            ViewData["ZprogramsId"]         = new SelectList(_context.Zprograms.Where(m => m.active).OrderBy(m => m.program_desc), "ZprogramsId", "program_desc", cs.ZprogramsId);
            ViewData["ZreasonId"]           = new SelectList(_context.Zreason.OrderBy(m => m.final_reason), "ZreasonId", "final_reason", cs.ZreasonId);
            ViewData["ZresourcereasonId"]   = new SelectList(_context.Zresourcereason.OrderBy(m => m.resourceresult), "ZresourcereasonId", "resourceresult", cs.ZresourcereasonId);
            ViewData["ZschoolId"]           = new SelectList(_context.Zschool.Where(m => m.active).OrderBy(m => m.displayname), "ZschoolId", "displayname", cs.ZschoolId);
            ViewData["ZsiteId"]             = new SelectList(_context.Zsite.Where(m => m.active).OrderBy(m => m.site), "ZsiteId", "site", cs.ZsiteId);
            ViewData["ZstatusId"]           = new SelectList(_context.Zstatus.Where(m => m.active).OrderBy(m => m.inq_status), "ZstatusId", "inq_status", cs.ZstatusId);
            ViewData["ZworkerId"]           = new SelectList(_context.Zworker.Where(m => m.active).OrderBy(m => m.worker), "ZworkerId", "worker", cs.ZworkerId);
            ViewData["ZcountyId"]           = new SelectList(_context.Zcounty.OrderBy(m => m.county), "ZcountyId", "county", client.ZcountyId);
            ViewData["ZraceId"]             = new SelectList(_context.Zrace.OrderBy(m => m.race), "ZraceId", "race", client.ZraceId);
            ViewData["ZinsuranceId"]        = new SelectList(_context.Zinsurance.Where(m => m.active).OrderBy(m => m.insurance), "ZinsuranceId", "insurance", client.ZinsuranceId);

            return(View(inquiryFormViewModel));
        }