public ActionResult Create(Visitors visitors, HttpPostedFileBase ProfileImage) { if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png")) { string filename = $"visitor_{visitors.ID}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/Images/{filename}")); visitors.Resim = filename; } if (ProfileImage == null) { visitors.Resim = "BaseUser.jpg"; } if (ModelState.IsValid) { visitors.Saat = DateTime.Now; var addedVisitor = _visitorsService.AddVisitor(visitors); _accessDatasService.AddOperatorLog(320, permissionUser.Kullanici_Adi, addedVisitor.Kayit_No, 0, 0, 0); return(RedirectToAction("Index")); } return(View(visitors)); }
public ActionResult Create(Visitors visitors) { if (ModelState.IsValid) { visitors.Saat = DateTime.Now; int MaxID; if (_userService.GetAllUsers().Count == 0) { MaxID = 0; } else { MaxID = _userService.GetAllUsers().Max(x => x.ID); } var userEntity = new Users { Adi = "Ziyaretci_" + visitors.Adi, Soyadi = "Ziyaretci_" + visitors.Soyadi, ID = MaxID + 1, Kart_ID = visitors.Kart_ID, Grup_No = visitors.Grup_No, Visitor_Grup_No = visitors.Grup_No, Aciklama = "QR Kodlu Sistem Ziyaretçisi", Kullanici_Tipi = 1, TCKimlik = visitors.TCKimlik, Telefon = visitors.Telefon, Resim = "BaseUser.jpg", Plaka = visitors.Plaka, Sirket_No = _sirketService.GetAllSirketler().FirstOrDefault().Sirket_No, Departman_No = _departmanService.GetAllDepartmanlar().FirstOrDefault().Departman_No, Alt_Departman_No = _altDepartmanService.GetAllAltDepartman().FirstOrDefault().Alt_Departman_No }; visitors.UseUserGroup = true; visitors.ID = MaxID + 1; var addedUser = _userService.AddUsers(userEntity); var addedVisitor = _visitorsService.AddVisitor(visitors); Send(PanelListesi, CommandConstants.CMD_SND_USER, addedUser.ID); _accessDatasService.AddOperatorLog(320, permissionUser.Kullanici_Adi, addedVisitor.Kayit_No, 0, 0, 0); return(RedirectToAction("PrintQRCode", new { KartID = visitors.Kart_ID })); } return(View(visitors)); }