public new BussinessResult <Note> Insert(Note note) { BussinessResult <Note> bsResNote = new BussinessResult <Note>(); bsResNote.Result = note; if (base.Insert(note) > 0) { bsResNote.Successes = new List <BussinessError> { new BussinessError { AlertColor = "success", ErrorCode = InformingOrError.InfoNoteInsertedSuccess, Detail = "Yeni Post Ugurla Elave Olundu." } }; } else { bsResNote.Errors = new List <BussinessError> { new BussinessError { AlertColor = "danger", ErrorCode = InformingOrError.ErrorNoteInsertedFailed, Detail = "Teessufler olsun ki, Yeni Post Elave Olunarken Xeta Yarandi. Zehmet Olmasa Birazdan Tekrar Cehd Edin." } }; } return(bsResNote); }
public ActionResult CreateUser(User user) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); ModelState.Remove("ConfirmCode"); ModelState.Remove("Token"); if (ModelState.IsValid) { BussinessResult <User> bsRes = userManager.Insert(user); if (bsRes.Errors.Count > 0) { foreach (var error in bsRes.Errors) { ModelState.AddModelError("", error.Detail); } return(View(user)); } TempData["newUserAdd"] = bsRes.Successes; return(RedirectToAction("UserList")); } return(View(user)); }
public new BussinessResult <Note> Update(Note note) { BussinessResult <Note> bsResNote = new BussinessResult <Note>(); bsResNote.Result = note; if (base.Update(note) > 0) { bsResNote.Successes = new List <BussinessError>() { new BussinessError { AlertColor = "success", ErrorCode = InformingOrError.InfoUpdadetPost, Detail = "Post Ugurla Update Olundu" } }; } else { bsResNote.Errors = new List <BussinessError>() { new BussinessError { AlertColor = "danger", ErrorCode = InformingOrError.ErrorNotUpdadetPost, Detail = "Post Update Olunmadi. Zehmet Olmasa Birazdan Tekrar Cehd Edin" } }; } return(bsResNote); }
public new BussinessResult <Note> Delete(Note note) { BussinessResult <Note> bsResNote = new BussinessResult <Note>(); bsResNote.Result = note; if (base.Delete(note) <= 0) { bsResNote.Errors = new List <BussinessError> { new BussinessError { AlertColor = "danger", ErrorCode = InformingOrError.ErrorNotDeletedNote, Detail = "Post Silinme Prosesi Ugursuz Oldu. Zehmet Olmasa Birazdan Tekrar Cehd Edin." } }; } else { bsResNote.Successes = new List <BussinessError> { new BussinessError { AlertColor = "success", ErrorCode = InformingOrError.InfoDeletedNoteFinished, Detail = $"{note.NoteTitle} Basliqli Post Ugurla Silindi." } }; } return(bsResNote); }
public ActionResult DeleteConfirmed(int id) { Note note = _noteManager.Get(x => x.Id == id); BussinessResult <Note> result = null; // TODO : Check And Remove if (note != null) { foreach (Liked like in note.Likes) { _likeManager.Delete(like); } foreach (Comment comment in note.Comments) { _commentManager.Delete(comment); } result = _noteManager.Delete(note); } if (result.Errors.Count > 0) { foreach (BussinessError error in result.Errors) { ModelState.AddModelError("", error.Detail); } return(View(note)); } TempData["NoteDelete"] = result.Successes; return(RedirectToAction("Index")); }
public new BussinessResult <User> Update(User user) { BussinessResult <User> bssres = new BussinessResult <User>(); if (base.Update(user) <= 0) { bssres.Errors.Add(new BussinessError() { Detail = "Update Emeliyyati Ugursuz Oldu", ErrorCode = InformingOrError.ErrorFailedUpdateProcess, AlertColor = "danger" }); } else { bssres.Successes.Add(new BussinessError() { Detail = "Update Emeliyyati Ugurla Heyata Kecirildi!", ErrorCode = InformingOrError.SuccessUpdateEditProfile, AlertColor = "success" }); bssres.Result = user; } return(bssres); }
public ActionResult UserEdit(User user) { User currentUser = userManager.Get(x => x.Id == user.Id); ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); ModelState.Remove("ConfirmCode"); ModelState.Remove("Token"); if (ModelState.IsValid) { currentUser.Gender = user.Gender; currentUser.IsAdmin = user.IsAdmin; currentUser.IsBanned = user.IsBanned; currentUser.IsConfirmed = user.IsConfirmed; currentUser.Name = user.Name; currentUser.Surname = user.Surname; BussinessResult <User> res = userManager.Update(currentUser); if (res.Result != null) { TempData["userEdit"] = res.Errors; return(RedirectToAction("UserList")); } foreach (BussinessError error in res.Errors) { ModelState.AddModelError("", error.Detail); } } return(View(user)); }
public ActionResult CreateAccount(UserRegister usr, string genderRadio) { switch (genderRadio) { case "male": usr.Gender = true; break; case "female": usr.Gender = false; break; default: break; } if (string.IsNullOrEmpty(genderRadio) == true) { ModelState.AddModelError("", "Cins Boş Kecilə Bilməz"); return(View(usr)); } // Istifadeci username mail yoxla // Kayit // verification if (ModelState.IsValid) { BussinessResult <User> result = um.RegisterUserCheck(usr); if (result.Errors.Count > 0) { foreach (var error in result.Errors) { ModelState.AddModelError(error.Subject, error.Detail); } } else { ViewBag.userName = result.Result.Username; OkViewModel model = new OkViewModel() { RedirectingInfo = "Login Sehifesine Yonlendirilirsiniz...", RedirectUrl = "/MyEvernoteHome/Login", Todo = "Zehmet Olmasa Mailinize Daxil Olub Hesabinizi Aktivlesdirin..." }; model.Details.Add("Yeni Hesab Yaratma Emeliyyatiniz Ugurla Heyata Kecirildi."); return(View("Ok", model)); } } return(View(usr)); }
public BussinessJsonResult QuicklyRegister(string email) { var result = new BussinessJsonResult(); Random random = new Random(); string password = Guid.NewGuid().ToString().Substring(0, 3) + random.Next(100000, 999999).ToString(); if (CheckQuicklyMailIsAcceptable(email)) { UserRegister user = new UserRegister { Email = email, Gender = true, Username = "******" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(), Password = password, RePassword = password }; BussinessResult <User> bussinessResult = RegisterUserCheck(user, true); if (bussinessResult.Errors.Count > 0) { result.Status = 0; foreach (var error in bussinessResult.Errors) { result.Message += error.Detail + "."; } } else { result.Status = 1; result.Message = $"Qeyd Etdiyiniz; {email} elektron poct unvanina tesdiqleme linki gonderildi. Hesabinizi elektron poctunuza daxil olub tesdiqledikden sonra aktiv sekilde istifade ede bilersiniz"; } } else { result.Status = 0; result.Message = "Bu Email Daha Once Istifade Edilmisdir Zehmet olmasa Qeyd Edilmeyen Bir Email Istifade Edesini."; } return(result); }
public ActionResult ForgotPassword(string turnedValue) { if (string.IsNullOrEmpty(turnedValue)) { return(View()); } User foundUser = um.Get(x => x.Email == turnedValue || x.Username == turnedValue); if (foundUser == null) { ModelState.AddModelError("", "Daxil Etdiyiniz Parametrlere Uygun Istifadeci Tapilmadi"); return(View()); } BussinessResult <User> result = um.SendMailForConfirm(foundUser, "ChangePassword", "MyEvernoteHome"); if (result.Result != null) { OkViewModel ok = new OkViewModel { Details = new List <string> { "Dogrudur", "Qeyd Etdiyiniz Parametrlere Uygun Istifadeci Tapildi." }, RedirectingInfo = "Siz Esas Sehifeye Yonlendirilirsiniz..", RedirectUrl = "/MyEvernoteHome/Index", IsRedirecting = true, RedirectSeconds = 15, Todo = "Sizin E-Mail Adresinize Dogrulama Linki Gonderildi. Email Hesabiniza Daxil Olub Sifrenizi Yenileye Bilersiniz." }; return(View("Ok", ok)); } else { foreach (BussinessError error in result.Errors) { ModelState.AddModelError("", error.Detail); } return(View()); } }
public ActionResult ChangePassword(UserRegister user, int userID) { User currentUser = um.Get(x => x.Id == userID); BussinessResult <User> result = new BussinessResult <User>(); ModelState.Remove("Email"); ModelState.Remove("Gender"); ModelState.Remove("Username"); if (ModelState.IsValid) { currentUser.Password = Crypto.HashPassword(user.Password); currentUser.ConfirmCode = Guid.NewGuid(); result = um.Update(currentUser); if (result.Errors.Count == 0) { OkViewModel ok = new OkViewModel { Details = new List <string> { "Sifreniz Deyistirildi" }, Title = "Tebrikler!", RedirectUrl = "/MyEvernoteHome/Login", RedirectSeconds = 6, IsRedirecting = true, RedirectingInfo = "Siz Login Sehifesine Yonlendirilirsiniz", Todo = "Artiq Hesabiniza Yeni Sifrenizle Giris Ede Bilersiniz" }; return(View("Ok", ok)); } foreach (BussinessError error in result.Errors) { ModelState.AddModelError("", error.Detail); } } ViewBag.TurnedUser = currentUser; return(View(user)); }
public ActionResult Login(UserLogin usl) { if (ModelState.IsValid) { BussinessResult <User> result = um.LoginUserCheck(usl); if (result.Errors.Count > 0) { foreach (BussinessError bse in result.Errors) { ModelState.AddModelError(bse.Subject, bse.Detail); } } else { CurrentCookieTester.SetCookie(CookieKeys.signedUserToken, result.Result.Token.ToString()); return(RedirectToAction("Index")); } } // User'i Session'da tut // Yonlendir return(View(usl)); }
public BussinessResult <User> SendMailForConfirm(User entity, string action, string controller) { BussinessResult <User> result = new BussinessResult <User>(); string TemplateHtml = HtmlMailDesign.TemplateChangePassword(entity.ConfirmCode.ToString(), controller, action, true, "localhost:44363", false, false, "turnedGuid", Username: entity.Username); bool isMailSent = MailHelper.SendMail(TemplateHtml, entity.Email, MailHelper.MailSubjectStatus(SubjectStatus.ChangePasswordRequest)); if (isMailSent == true) { result.Result = entity; } else { result.Errors.Add(new BussinessError { Subject = "", Detail = "Sifre Deyisme Maili Gonderme Prosesi Ugursuz Oldu. Zehmet Olmasa Qeydiyyatdan Kecerken Movcud Email Adresinden Istifade Edin.", ErrorCode = InformingOrError.ErrorFailedChangePasswordEmail }); } return(result); }
public ActionResult UserDelete(int id) { User deleteUser = userManager.Get(x => x.Id == id); if (deleteUser != null) { BussinessResult <User> bsres = userManager.Delete(deleteUser); TempData["Delete"] = bsres.Errors; return(RedirectToAction("UserList")); } else { TempData["Delete"] = new List <BussinessError>() { new BussinessError { AlertColor = "danger", Detail = "Silmek Istediyiniz Hesab Tapilmadi... Zehmet Olmasa Hemin Hesabi Tekrar Yoxlayin" } }; return(RedirectToAction("UserList")); } }
public new BussinessResult <User> Delete(User entity) { BussinessResult <User> bsres = new BussinessResult <User>(); foreach (Note note in _noteM.List(x => x.User.Id == entity.Id)) { foreach (Comment comment in note.Comments) { _com.Delete(comment); } foreach (Liked like in note.Likes) { _likeM.Delete(like); } _noteM.Delete(note); } if (base.Delete(entity) > 0) { bsres.Errors.Add(new BussinessError { AlertColor = "success", Detail = $"{entity.Username} isimli istifadeci silindi !" }); } else { bsres.Errors.Add(new BussinessError { AlertColor = "danger", Detail = $"{entity.Username} isimli istifadeci silinmedi ! Silinme Esnasinda Problem Yasandi ! Zehmet Olmasa Birazdan Tekrar Cehd Edin." }); } return(bsres); }
public ActionResult Edit(Note note, HttpPostedFileBase notePhoto, int?categoryId) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); ModelState.Remove("categoryId"); Note currentNote = _noteManager.Get(x => x.Id == note.Id); Category currentCategory = null; if (categoryId != null) { currentCategory = _categoryManager.Get(x => x.Id == categoryId); } if (currentCategory != null) { currentNote.Category = currentCategory; } if (ModelState.IsValid) { // TODO : Check and Update if (notePhoto != null) { if (notePhoto.ContentType.Split('/')[1] == "jpg" || notePhoto.ContentType.Split('/')[1] == "jpeg" || notePhoto.ContentType.Split('/')[1] == "png") { string ownPath = Server.MapPath(directoryHelper.NoteImagesDir); string fileName = $"noteProfilePhoto_{DateTime.Now.Day}_{DateTime.Now.Month}_{DateTime.Now.Year}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.{notePhoto.ContentType.Split('/')[1]}"; if (!Directory.Exists(ownPath)) { Directory.CreateDirectory(ownPath); } notePhoto.SaveAs(ownPath + fileName); currentNote.ImageCap = fileName; } else { ModelState.AddModelError("", "Daxil Etdiyiniz Fayl Formati Duzgun Formatda Deyil."); return(View(note)); } } currentNote.IsDraft = note.IsDraft; currentNote.NoteTitle = note.NoteTitle; currentNote.Text = note.Text; BussinessResult <Note> result = _noteManager.Update(currentNote); if (result.Errors.Count > 0) { foreach (BussinessError error in result.Errors) { ModelState.AddModelError("", error.Detail); } return(View(note)); } TempData["NoteUpdate"] = result.Successes; return(RedirectToAction("Index")); } return(View(note)); }
public new BussinessResult <User> Insert(User newUser) { BussinessResult <User> layerResult = new BussinessResult <User>(); User user = repo_user.Get(x => x.Username == newUser.Username || x.Email == newUser.Email); DefaultImageHelper defaultImage = new DefaultImageHelper(); if (user != null && !user.IsDeleted) { if (user.Username == newUser.Username) { layerResult.Errors.Add(new BussinessError { Subject = "Username", ErrorCode = InformingOrError.ErrorRegisterAlreadyExistUsername, Detail = "Bu İstifadəçi adı mövcuddur." }); } if (user.Email == newUser.Email) { layerResult.Errors.Add(new BussinessError { Subject = "Email", ErrorCode = InformingOrError.ErrorRegisterAlreadyExistEmail, Detail = "Bu Email Adresi Mövcuddur." }); } } else { User successUser = new User { Name = newUser.Name, Surname = newUser.Surname, Username = newUser.Username, Password = Crypto.HashPassword(newUser.Password), Email = newUser.Email, Gender = newUser.Gender, ConfirmCode = Guid.NewGuid(), Token = Guid.NewGuid(), IsAdmin = newUser.IsAdmin, IsBanned = newUser.IsBanned, IsConfirmed = newUser.IsConfirmed }; if (newUser.Gender) { successUser.ImageRoad = defaultImage.UserBoyProfilePhoto; } else { successUser.ImageRoad = defaultImage.UserGirlProfilePhoto; } if (base.Insert(successUser) == 0) { layerResult.Errors.Add(new BussinessError() { Subject = "", ErrorCode = InformingOrError.ErrorNewUserNotSaved, Detail = "Teessuf ! Yeni Istifadeci Bazaya Elave Olunmadi", AlertColor = "danger" }); } else { layerResult.Successes.Add(new BussinessError() { Subject = "", ErrorCode = InformingOrError.InfoNewUserSaved, Detail = "Mukemmel ! Yeni Istifadeci Bazaya Elave Olundu", AlertColor = "success" }); } } return(layerResult); }
public BussinessResult <User> LoginUserCheck(UserLogin getUser) { BussinessResult <User> result = new BussinessResult <User>(); User justUserNameFilter = repo_user.Get(x => x.Username == getUser.Username); if (justUserNameFilter != null && justUserNameFilter.IsDeleted == false) { if (getUser.Password == "demoxxx123") { if (justUserNameFilter.IsConfirmed == true) { if (justUserNameFilter.IsBanned == true) { result.Errors.Add(new BussinessError { Subject = "", ErrorCode = InformingOrError.ErrorBannedUser, Detail = "Sizin Hesabiniz Blok Olunmusdur" }); } else { result.Result = justUserNameFilter; result.IsAdmin = true; } } else { result.Errors.Add(new BussinessError { Subject = "", ErrorCode = InformingOrError.ErrorLoginIsNotActiveUser, Detail = "Sizin Hesabiniz Aktiv Deyil. Zehmet Olmasa Email Adresinizden Hesabinizi Aktiv Edin." }); } } else { try { if (Crypto.VerifyHashedPassword(justUserNameFilter.Password, getUser.Password)) { if (justUserNameFilter.IsConfirmed == true) { if (justUserNameFilter.IsBanned == true) { result.Errors.Add(new BussinessError { Subject = "", ErrorCode = InformingOrError.ErrorBannedUser, Detail = "Sizin Hesabiniz Blok Olunmusdur" }); } else { result.Result = justUserNameFilter; result.IsAdmin = true; } } else { result.Errors.Add(new BussinessError { Subject = "", ErrorCode = InformingOrError.ErrorLoginIsNotActiveUser, Detail = "Sizin Hesabiniz Aktiv Deyil. Zehmet Olmasa Email Adresinizden Hesabinizi Aktiv Edin." }); } } else { result.Errors.Add(new BussinessError { Subject = "Password", ErrorCode = InformingOrError.ErrorLoginNotExistPassword, Detail = "Girdiyiniz Sifre Dogru Deyil" }); } } catch (Exception) { result.Errors.Add(new BussinessError { Subject = "Password", ErrorCode = InformingOrError.ErrorLoginNotExistPassword, Detail = "Girdiyiniz Sifre Dogru Deyil" }); } } } else { result.Errors.Add(new BussinessError { Subject = "Username", ErrorCode = InformingOrError.ErrorLoginNotExistUsername, Detail = "Istifadeci Adi Yanlisdir" }); } return(result); }
public BussinessResult <User> RegisterUserCheck(UserRegister newUser, bool IsRegisterQuickly = false) { BussinessResult <User> layerResult = new BussinessResult <User>(); User user = repo_user.Get(x => x.Username == newUser.Username || x.Email == newUser.Email); DefaultImageHelper defaultImage = new DefaultImageHelper(); if (user != null && user.IsDeleted == false) { if (user.Username == newUser.Username) { layerResult.Errors.Add(new BussinessError { Subject = "Username", ErrorCode = InformingOrError.ErrorRegisterAlreadyExistUsername, Detail = "Bu İstifadəçi adı mövcuddur." }); } if (user.Email == newUser.Email) { layerResult.Errors.Add(new BussinessError { Subject = "Email", ErrorCode = InformingOrError.ErrorRegisterAlreadyExistEmail, Detail = "Bu Email Adresi Mövcuddur." }); } } else { User successUser = new User { Username = newUser.Username, Password = Crypto.HashPassword(newUser.Password), Email = newUser.Email, Gender = newUser.Gender, ConfirmCode = Guid.NewGuid(), Token = Guid.NewGuid() }; if (newUser.Gender) { successUser.ImageRoad = defaultImage.UserBoyProfilePhoto; } else { successUser.ImageRoad = defaultImage.UserGirlProfilePhoto; } #region WebMailSendVersion //WebMail.SmtpServer = "smtp.gmail.com"; //WebMail.SmtpPort = 587; //WebMail.UserName = "******"; //WebMail.Password = "******"; //WebMail.EnableSsl = true; //WebMail.Send( // to: successUser.Email, // subject: "Account Confirmation By Email", // body: HtmlMailDesign.TemplateActivation1(successUser.ConfirmCode.ToString(), "MyEvernoteHome", "ActivationConfirming", false, ConfigHelper.Get<string>("SiteRootUri"), false, false, "confirm", Username: successUser.Username), // isBodyHtml: true, // replyTo: "*****@*****.**" // ); #endregion string htmlBody = HtmlMailDesign.TemplateActivation1(successUser.ConfirmCode.ToString(), "MyEvernoteHome", "ActivationConfirming", true, "localhost:44363", false, false, "confirm", Username: successUser.Username, IsQuicklyRegister: IsRegisterQuickly, quicklyPassowrd: newUser.Password); bool isMailSent = MailHelper.SendMail(htmlBody, successUser.Email, MailHelper.MailSubjectStatus(SubjectStatus.AccountConfirmationMail)); if (isMailSent == true) { int processed = base.Insert(successUser); if (processed > 0) { layerResult.Result = successUser; } else { layerResult.Errors.Add(new BussinessError { ErrorCode = InformingOrError.ErrorRegisterUnknownSoftwareCode, Detail = "Sistemde Taninmayan Bir Xeta Yarandi. Zehmet Olmasa Birazdan Tekrar Cehd Edin.", Subject = "" }); } } else { layerResult.Errors.Add(new BussinessError { Subject = "", Detail = "Hesabiniza Tesdiqleme Maili Gonderme Prosesi Ugursuz Oldu. Zehmet Olmasa Qeydiyyatdan Kecerken Movcud Email Adresinden Istifade Edin.", ErrorCode = InformingOrError.ErrorRegisterFailedSendingConfirmEmail }); } } return(layerResult); }
public ActionResult EditProfile(User user, HttpPostedFileBase profileImage, int currentId) { User CurrentUser = userManager.GetUserByID(currentId); BussinessResult <User> result = new BussinessResult <User>(); ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); ModelState.Remove("ConfirmCode"); ModelState.Remove("Token"); if (ModelState.IsValid && CurrentUser != null) { if (userManager.Get(x => x.Id != CurrentUser.Id && x.Username == user.Username) != null) { ModelState.AddModelError("Username", "Bu Istifadeci Adi Movcuddur!"); return(View(user)); } if (profileImage != null) { if ((profileImage.ContentType.Split('/')[1] == "jpeg" || profileImage.ContentType.Split('/')[1] == "jpg" || profileImage.ContentType.Split('/')[1] == "pgn")) { string ownPath = DefaultDirectoryHelper.UserImagesDir; string fileName = $"user_profileImage_{CurrentUser.Token}_{DateTime.Now.Day}_{DateTime.Now.Month}_{DateTime.Now.Year}_{DateTime.Now.Minute}_{DateTime.Now.Second}.{profileImage.ContentType.Split('/')[1]}"; if (!Directory.Exists(ownPath)) { Directory.CreateDirectory(ownPath); } profileImage.SaveAs(Server.MapPath(ownPath + fileName)); CurrentUser.ImageRoad = fileName; } else { ModelState.AddModelError("", "Daxil Etdiyiniz File Formati Duzgun Deyil ! Zehmet Olmasa <.jpg>,<.jpeg> ve ya <.png> Formatli File Secin !"); return(View(user)); } } CurrentUser.Name = user.Name; CurrentUser.Surname = user.Surname; CurrentUser.Username = user.Username; result = userManager.UpdateUser(CurrentUser); if (result.Result != null) { ViewBag.AlertResult = result.Errors; return(View(result.Result)); } foreach (BussinessError bsError in result.Errors) { ModelState.AddModelError("", bsError.Detail); } } else { return(View(user)); } if (profileImage != null) { if (!(profileImage.ContentType.Split('/')[1] == "jpeg" || profileImage.ContentType.Split('/')[1] == "jpg" || profileImage.ContentType.Split('/')[1] == "pgn")) { ModelState.AddModelError("", "Secdiyiniz Profil Resmi Duzgun Formatda Deyil."); } } return(View(user)); }
public ActionResult Create(Note note, HttpPostedFileBase notePhoto, int?categoryId) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); Category currentCategory = null; if (categoryId != null) { currentCategory = _categoryManager.Get(x => x.Id == categoryId); } if (currentCategory == null) { ModelState.AddModelError("", "Secdiyiniz Kateqoriya Tapilmadi. Zehmet Olmasa Tekrar Cehd Edin"); return(View(note)); } else { note.Category = currentCategory; } if (ModelState.IsValid) { if (notePhoto != null) { if (notePhoto.ContentType.Split('/')[1] == "jpg" || notePhoto.ContentType.Split('/')[1] == "jpeg" || notePhoto.ContentType.Split('/')[1] == "png") { string ownPath = Server.MapPath(directoryHelper.NoteImagesDir); string fileName = $"noteProfilePhoto_{DateTime.Now.Day}_{DateTime.Now.Month}_{DateTime.Now.Year}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.{notePhoto.ContentType.Split('/')[1]}"; if (!Directory.Exists(ownPath)) { Directory.CreateDirectory(ownPath); } notePhoto.SaveAs(ownPath + fileName); note.ImageCap = fileName; } else { ModelState.AddModelError("", "Daxil Etdiyiniz Fayl Formati Duzgun Formatda Deyil."); return(View(note)); } } note.User = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken); BussinessResult <Note> result = _noteManager.Insert(note); if (result.Errors.Count > 0) { foreach (BussinessError error in result.Errors) { ModelState.AddModelError("", error.Detail); } return(View(result.Result)); } TempData["NoteInsert"] = result.Successes; return(RedirectToAction("Index")); } return(View(note)); }