public async Task <IActionResult> Ekle(News news, IFormFile Image) { if (Image == null || Image.Length == 0) { news.Photo = "defaultnews.png"; } else { string newImage = Guid.NewGuid().ToString() + Image.FileName; var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\Haberler", newImage); using (var stream = new FileStream(path, FileMode.Create)) { await Image.CopyToAsync(stream); } news.Photo = newImage; } var cont = news.Content.Replace("\r", ""); news.Content = cont.Replace("\n", " "); newsDb.Add(news); TempData["AddMessage"] = "Yeni Haber Başarıyla Eklendi."; return(RedirectToAction("Index", "YoneticiHaber")); }
public IActionResult Iletisim(Contact contact) { if (contact.Title.Length > 1 && contact.Message.Length > 1) { contact.Date = DateTime.Now.ToShortDateString(); contactDb.Add(contact); TempData["SendMessageSuccess"] = "Mesaj Başarıyla Gönderildi."; return(RedirectToAction("Iletisim")); } return(View()); }
void CreateContactMessage() { if (contactDb.GetAll().Count < 1) { Contact contact = new Contact(); contact.Name = "Berke"; contact.Surname = "Kurnaz"; contact.Mail = "*****@*****.**"; contact.Title = "Mesaj Bölümüne Hoşgeldin."; contact.Message = "Merhaba Burası Mesaj Bölümü. Burada Mesajları Okuyabilir Ve Silebilirsin."; contact.Date = DateTime.Now.ToShortDateString(); contactDb.Add(contact); } }
/* The task of this method is to add new teacher */ private void btnNewTeacher_Click(object sender, EventArgs e) { var result = MessageBox.Show("Do you want to add this teacher ?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Teacher teacher = new Teacher(); teacher.TeacherName = txtNameSurname.Text; teacher.Class = Convert.ToInt16(txtClass.Text); teacherDb.Add(teacher); MessageBox.Show("Added New Teacher."); ShowAllTeachers(); ShowStatistics(); } }
/* The task of this method is to add new student */ private void btnNewStudent_Click(object sender, EventArgs e) { var result = MessageBox.Show("Do you want to add this student ?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Student student = new Student(); student.NameSurname = txtNameSurname.Text; student.Number = txtNumber.Text; student.Class = Convert.ToInt16(txtClass.Value); student.Grade = Convert.ToInt16(txtGrade.Text); student.TeacherName = cmbTeacherName.Text; studentDb.Add(student); MessageBox.Show("Added New Student."); ShowAllStudents(); ShowStatistics(); } }
public async Task <IActionResult> Ekle(Team team, IFormFile Image) { if (Image == null || Image.Length == 0) { team.Photo = "defaultteam.png"; } else { string newImage = Guid.NewGuid().ToString() + Image.FileName; var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\Ekip", newImage); using (var stream = new FileStream(path, FileMode.Create)) { await Image.CopyToAsync(stream); } team.Photo = newImage; } teamDb.Add(team); TempData["AddMessage"] = "Yeni Üye Başarıyla Eklendi."; return(RedirectToAction("Index")); }
static void Main(string[] args) { SaklambacDb <Note> saklambacDb = new SaklambacDb <Note>(); Console.WriteLine("Add New Note"); Note note = new Note(); note.Title = "Test01"; note.Description = "Test01 Description"; note.isCompleted = false; saklambacDb.Add(note); Console.WriteLine("List All Notes"); List <Note> notes = saklambacDb.GetAll(); foreach (var item in notes) { Console.WriteLine(item.Id + "/" + item.Title + "/" + item.Description + "/" + item.isCompleted); } Console.ReadLine(); }
public ActionResult Add(Movie movie) { movieDb.Add(movie); return(RedirectToAction("Index", "Home")); }
public ActionResult Index(Contact contact) { contact.CreatedDate = DateTime.Now.ToShortDateString(); saklambacDb.Add(contact); return(RedirectToAction("Index")); }
public IActionResult Add(Blog blog) { blogDb.Add(blog); return(RedirectToAction("Index", "Admin")); }
public IActionResult Ekle(User user) { userDb.Add(user); TempData["AddMessage"] = "Kullanıcı Başarıyla Eklendi."; return(RedirectToAction("Index")); }
public ActionResult Add(Director director) { directorDb.Add(director); return(RedirectToAction("Index", "Home")); }