Exemplo n.º 1
0
        public string addAdmin(Administrator tempAdmin)
        {
            try
            {
                using (var context = new MailRecorderDBEntities())
                {
                    ADMIN admin = new ADMIN
                    {
                        ADMIN_NAME     = tempAdmin.getAdminName(),
                        ADMIN_UNAME    = tempAdmin.getAdminUname(),
                        ADMIN_PASSWORD = tempAdmin.getAdminPword()
                    };

                    if (context.ADMINs.Any(x => x.ADMIN_UNAME == admin.ADMIN_UNAME))
                    {
                        return(null);
                    }
                    else
                    {
                        context.ADMINs.Add(admin);
                        context.SaveChanges();

                        return(admin.ADMIN_UNAME);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 2
0
 public string updateCustomer(Mail mail, int id)
 {
     try
     {
         using (var context = new MailRecorderDBEntities())
         {
             MAIL mailUp = context.MAILs.Where(x => x.Id == id).FirstOrDefault <MAIL>();
             mailUp.Id            = mail.getmailID();
             mailUp.DIARY_NO      = mail.getDiaryNo();
             mailUp.MRDIARY_NO    = mail.getmrDiary();
             mailUp.SUBJECT       = mail.getSubject();
             mailUp.DATE_SENT     = mail.getDateSent();
             mailUp.DATE_TODAY    = mail.getDateToday();
             mailUp.INITIATOR     = mail.getInitiator();
             mailUp.RECEIVED_FROM = mail.getRecievedFrom();
             mailUp.SENT_TO       = mail.getSentTo();
             mailUp.CC            = mail.getCc();
             mailUp.REMARKS       = mail.getRemarks();
             context.SaveChanges();
             return(mailUp.DIARY_NO.ToString());
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 3
0
 public string addMail(Mail tempMail)
 {
     try
     {
         using (var context = new MailRecorderDBEntities())
         {
             var mail = new MAIL()
             {
                 Id            = tempMail.getmailID(),
                 DIARY_NO      = tempMail.getDiaryNo(),
                 MRDIARY_NO    = tempMail.getmrDiary(),
                 SUBJECT       = tempMail.getSubject(),
                 DATE_SENT     = tempMail.getDateSent(),
                 DATE_TODAY    = tempMail.getDateToday(),
                 INITIATOR     = tempMail.getInitiator(),
                 RECEIVED_FROM = tempMail.getRecievedFrom(),
                 SENT_TO       = tempMail.getSentTo(),
                 CC            = tempMail.getCc(),
                 REMARKS       = tempMail.getRemarks()
             };
             context.MAILs.Add(mail);
             context.SaveChanges();
             return(mail.SUBJECT);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 4
0
 public string deleteMail(int id)
 {
     using (var context = new MailRecorderDBEntities())
     {
         var author = new MAIL {
             Id = id
         };
         context.Entry(author).State = EntityState.Deleted;
         context.SaveChanges();
         return(author.Id.ToString());
     }
 }