public async Task <IActionResult> Edit(string id, [Bind("CtypeName")] CharityType charityType) { if (id != charityType.CtypeName) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(charityType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CharityTypeExists(charityType.CtypeName)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(charityType)); }
public async Task <IActionResult> Create([Bind("CtypeName")] CharityType charityType) { if (ModelState.IsValid) { _context.Add(charityType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(charityType)); }
private bool loadCharitiesCategoryFiles(string FileName) { charityTypesOrigionalTable = new Dictionary <int, CharityType>(); charityTypesConvertedTable = new Dictionary <int, int>(); try { FileStream file = new FileStream(FileName, FileMode.Open); StreamReader reader = new StreamReader(file); if (!reader.EndOfStream) { reader.ReadLine(); } while (!reader.EndOfStream) { string line = reader.ReadLine(); string[] values = line.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Replace("***", ",").Trim(); } if (values.Length == 0) { continue; } int key = int.Parse(values[0]); CharityType value = new CharityType(values[1], values[3]); if (charityTypesOrigionalTable.ContainsKey(key)) { continue; } charityTypesOrigionalTable.Add(key, value); charityTypesConvertedTable.Add(key, charityTypesConvertedTable.Keys.Count() + 1); } file.Close(); reader.Close(); return(true); } catch { MessageBox.Show("Categories Error"); return(false); } }