public ReturnModel SetUpNewPassword(Guid securityCode, string newPassword) { try { Member member = context.ForgotPassword.Where(fp => fp.SecurityCode == securityCode && fp.LastValid >= DateTimeOffset.Now).Select(fp => fp.UsernameNavigation).FirstOrDefault(); if (member == null) { return(new ReturnModel { ErrorCode = ErrorCodes.ItemNotFoundError }); } (member.CryptoPassword, member.CryptoSalt) = cryptoHelpers.EncryptWithPBKDF2(newPassword); context.Entry(member).State = EntityState.Modified; foreach (var p in context.Set <ForgotPassword>().Where(fp => fp.Username == member.Username)) { context.Entry(p).State = EntityState.Deleted; } context.SaveChanges(); return(new ReturnModel { ErrorCode = ErrorCodes.OK }); } catch { return(new ReturnModel { ErrorCode = ErrorCodes.DatabaseError }); } // -1 }
// Bir kişinin organizasyondan/şirketten çıkarılması sonucu ilgili proje, iş konuşması vb. kayıtların yeniden düzenlenmesi void RemoveMemberFromOtherFeatures(TeamMember tMember) { try { // silinen takım üyesi takımın sahibi mi? if (tMember.Team.Owner == tMember.Username) { return; // Hiçbir şey yapma. } //kişi silindiği takımın sahibinin başka bir takımında yer alıyor mu? TeamMember inOtherTeams = context.Team.Where(t => t.Owner == tMember.Team.Owner && t.TeamId != tMember.TeamId). SelectMany(t => t.TeamMember).Where(tm => tm.Username == tMember.Username && tm.Status == true).FirstOrDefault(); if (inOtherTeams != null) { return; // Hiçbir şey yapma. } // burada tüm kayıtları gerekli sırada sil veya yeniden düzenle. foreach (var p in context.Set <QuickTaskComment>().Where(qtc => qtc.Task.Owner != tMember.Username && qtc.Sender == tMember.Username)) { p.Sender = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <QuickTask>().Where(qt => qt.Owner != tMember.Username && qt.AssignedTo == tMember.Username)) { p.AssignedTo = null; p.Completedby = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <ProjectTaskComment>().Where(ptc => ptc.Task.Project.Owner != tMember.Username && ptc.Sender == tMember.Username)) { p.Sender = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <ProjectTask>().Where(pt => pt.Project.Owner != tMember.Username && pt.AssignedTo == tMember.Username)) { p.AssignedTo = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <Project>().Where(p => p.Owner != tMember.Username && p.ProjectManager == tMember.Username)) { p.ProjectManager = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <PrivateTalkReceiver>().Where(ptr => ptr.PrivateTalk.Owner != tMember.Username && ptr.Receiver == tMember.Username)) { context.Entry(p).State = EntityState.Deleted; } foreach (var p in context.Set <PrivateTalkLastSeen>().Where(ptls => ptls.PrivateTalk.Owner != tMember.Username && ptls.Visitor == tMember.Username)) { context.Entry(p).State = EntityState.Deleted; } foreach (var p in context.Set <PrivateTalkMessage>().Where(ptm => ptm.PrivateTalk.Owner != tMember.Username && ptm.Sender == tMember.Username)) { p.Sender = null; context.Entry(p).State = EntityState.Modified; } foreach (var p in context.Set <PrivateTalk>().Where(pt => pt.Owner != tMember.Username && pt.Sender == tMember.Username)) { p.Sender = null; context.Entry(p).State = EntityState.Modified; } } catch { return; } }