public async Task <IActionResult> Create(
            // RADER:
            // I think here I do NOT need ID, org ID, or Org org
            // because those aren't values input by the user, but rather are
            // connected behind the scenes by us!
            [Bind("Street_Address,City,Zip,Phone,Email,Website")] Contact contact)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(contact);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(contact));
        }
        public async Task <IActionResult> Create([Bind("TimesId,Time_Start,Time_End,Repeat,Day,OrganizationId")] Time time)
        {
            if (ModelState.IsValid)
            {
                _context.Add(time);

                await _context.SaveChangesAsync();

                return(RedirectToAction("AddTimes", "Times", new { id = time.OrganizationId }));
            }

            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "Name", time.OrganizationId);
            return(View(time));
        }
        public async Task <IActionResult> Create([Bind("Id,OrganizationId,Street_Address,City,Zip,Email,Phone,Website")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);


                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "Resources", new { id = contact.OrganizationId }));
            }
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "Name", contact.OrganizationId);
            return(View(contact));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(int id, [Bind("Id,OrganizationId,Clothing,Education,Employment,Finances,Food,Housing,Natural_Disaster,Senior,Rent_Utilities,Medical_Prescription,Veterans,Other_Resources,Other_Resources_Text")] Resource resource)
        {
            if (id != resource.Id)
            {
                return(NotFound());
            }


            if (ModelState.IsValid)
            {
                _context.Add(resource);

                _context.Organizations.Where(m => m.Id == id).FirstOrDefault().Last_Updated = DateTime.Now.ToString();
                await _context.SaveChangesAsync();

                return(RedirectToAction("AddTimes", "Times", new { id = resource.OrganizationId }));
            }
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "Name", resource.OrganizationId);
            return(View(resource));
        }
        public async Task <IActionResult> Create(
            [Bind("Name,Photo_ID,Other_Requirements,Other_Requirements_Text,Appointments_Available,Appointments_Required,Additional_Comments,Last_Updated")] Organization organization)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(organization);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Create", "Contacts", new { id = organization.Id }));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(organization));
        }