public async Task <IActionResult> Edit(int id, [Bind("Id,Empid,Name,Surname,Gender,DateofBirth,Email,Posti,Statusi,DateofFire")] EmploeeModel emploeeModel) { if (id != emploeeModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { bool checkmail = (from email in _context.Emploees where email.Email == emploeeModel.Email select email).Any(); bool checkid = (from Id in _context.Emploees where Id.Empid == emploeeModel.Empid select Id).Any(); if (checkmail) { ViewBag.Message = "Aseti Meilit Registrirebuli tanamshromeli ukve arsebobs"; return(View(emploeeModel)); } if (checkid) { ViewBag.Message = "Aseti tanamshromeli ukve arsebobs"; return(View(emploeeModel)); } _context.Update(emploeeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmploeeModelExists(emploeeModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(emploeeModel)); }
public async Task <IActionResult> Create([Bind("Id,Empid,Name,Surname,Gender,DateofBirth,Email,Posti,Statusi,DateofFire")] EmploeeModel emploeeModel) { if (ModelState.IsValid) { bool checkmail = (from email in _context.Emploees where email.Email == emploeeModel.Email select email).Any(); bool checkid = (from id in _context.Emploees where id.Empid == emploeeModel.Empid select id).Any(); if (checkmail) { ViewBag.Message = "Aseti Meilit Registrirebuli tanamshromeli ukve arsebobs"; return(View(emploeeModel)); } if (checkid) { ViewBag.Message = "Aseti tanamshromeli ukve arsebobs"; return(View(emploeeModel)); } ViewBag.Message = "tanamshromeli Warmatebit Damaemata"; _context.Add(emploeeModel); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); } return(View(emploeeModel)); }