Beispiel #1
0
 public static string NoteUpdate(NoteViews note)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             TblNote upnote = db.TblNote.Find(note.ID);
             if (upnote != null)
             {
                 upnote.Title            = note.Title;
                 upnote.Description      = note.Description;
                 upnote.ReminderDate     = note.ReminderDate;
                 upnote.İmportantyDegree = note.İmportantyDegree;
                 db.SaveChanges();
                 return("+ note guncellendi.");
             }
             else
             {
                 return("- note bulunamadi.");
             }
         }
     }
     catch (Exception ex)
     {
         return("- " + ex.Message);
     }
 }
Beispiel #2
0
 public static userView Login(string nickName, string pass)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             userView u = (from ku in db.TblUser where ku.Nickname == nickName && ku.Password == pass && ku.Existing == true ||
                           ku.Email == nickName && ku.Password == pass && ku.Existing == true select new userView {
                 Surname = ku.Surname,
                 Nickname = ku.Nickname,
                 Name = ku.Name,
                 Email = ku.Email,
                 Photo = ku.Photo,
                 ID = ku.ID
             }).SingleOrDefault();
             if (u != null)
             {
                 return(u);
             }
             else
             {
                 return(null);
             }
         };
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #3
0
 public static string SignUp(userView newUser)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             TblUser nUser = new TblUser {
                 Name = newUser.Name, Email = newUser.Email, Nickname = newUser.Nickname, Photo = newUser.Photo, Password = newUser.Password, Surname = newUser.Surname, BirthDate = newUser.BirtDate
             };
             nUser.JoinDate = DateTime.Now;
             nUser.Existing = true;
             db.TblUser.Add(nUser);
             db.SaveChanges();
             return("+ okey");
         };
     }
     catch (Exception ex)
     {
         return("- " + ex.Message);
     }
 }
Beispiel #4
0
 public static List <NoteViews> listNote(int ID)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             List <NoteViews> listnote = new List <NoteViews>();
             var n = (from note in db.TblNote where note.UserID == ID orderby note.WritingDate select note).ToList();
             foreach (var item in n)
             {
                 listnote.Add(new NoteViews {
                     ID          = item.ID, Title = item.Title, Description = item.Description, ReminderDate = (DateTime)item.ReminderDate,
                     WritingDate = (DateTime)item.WritingDate, İmportantyDegree = (int)item.İmportantyDegree
                 });
             }
             return(listnote);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #5
0
 public static string NoteAdd(NoteViews newnote)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             TblNote new_note = new TblNote
             {
                 Title            = newnote.Title,
                 Description      = newnote.Description,
                 ReminderDate     = newnote.ReminderDate,
                 İmportantyDegree = newnote.İmportantyDegree,
             };
             db.TblNote.Add(new_note);
             db.SaveChanges();
             return("+ Note eklendi");
         }
     }
     catch (Exception ex)
     {
         return("- " + ex.Message);
     }
 }
Beispiel #6
0
 public static string DeleteNote(int noteID)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             TblNote delnote = db.TblNote.Find(noteID);
             if (delnote != null)
             {
                 delnote.Existing = false;
                 return("+ Silindi.");
             }
             else
             {
                 return("- not bulunamadı.");
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return("- " + ex.Message);
     }
 }
Beispiel #7
0
 public userView getUser(int UID)
 {
     try
     {
         using (WebdeNotEntities db = new WebdeNotEntities())
         {
             TblUser getUser = db.TblUser.Find(UID);
             return(new userView
             {
                 Surname = getUser.Surname,
                 Nickname = getUser.Nickname,
                 Name = getUser.Name,
                 Email = getUser.Email,
                 Photo = getUser.Photo,
                 ID = getUser.ID,
                 Age = Convert.ToDateTime(DateTime.Now - getUser.BirthDate).Year
             });
         };
     }
     catch (Exception ex)
     {
         return(null);
     }
 }