Example #1
0
        public void CreateOrUpdateUser(User User)
        {
            try
            {
                if (User != null)
                {
                    //check whether the user exists already or not
                    User Userexists = PSF.Get <User>("UserId", User.UserId.Trim());

                    if (Userexists == null)
                    {
                        PSF.Save <User>(User);
                    }
                    else if (Userexists != null && Userexists.Id == User.Id)
                    {
                        PSF.SaveOrUpdate <User>(User);
                    }
                    else
                    {
                        throw new Exception("User already exists for " + User.UserId.Trim() + ".");
                    }
                }
                else
                {
                    PSF.Save <User>(User);
                }
                return;
            }
            catch (Exception)
            {
                throw;
            }
        }
 public long SaveOrUpdateInvoice(Invoice Iv, string userId)
 {
     try
     {
         if (Iv != null && Iv.Id > 0)
         {
             Iv.ModifiedBy   = userId;
             Iv.ModifiedDate = DateTime.Now;
             PSF.Update <Invoice>(Iv);
         }
         else
         {
             Iv.CreatedBy   = userId;
             Iv.CreatedDate = DateTime.Now;
             PSF.Save <Invoice>(Iv);
         }
         return(Iv.Id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long SaveOrUpdateMailTemplate(MailTemplate Mt, string userId)
 {
     try
     {
         if (Mt != null && Mt.MailTemplateId > 0)
         {
             Mt.ModifiedBy   = userId;
             Mt.ModifiedDate = DateTime.Now;
             PSF.Update <MailTemplate>(Mt);
         }
         else
         {
             Mt.CreatedBy    = userId;
             Mt.CreatedDate  = DateTime.Now;
             Mt.ModifiedDate = null;
             PSF.Save <MailTemplate>(Mt);
         }
         return(Mt.MailTemplateId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public long CreateOrUpdateEmailLog(EmailLog Mt)
 {
     try
     {
         if (Mt != null && Mt.Id > 0)
         {
             PSF.Update <EmailLog>(Mt);
         }
         else
         {
             PSF.Save <EmailLog>(Mt);
         }
         return(Mt.Id);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #5
0
 public string SaveOrUpdateTicketSystem(TicketSystem TicketSystem)
 {
     try
     {
         if (TicketSystem.Id > 0)
         {
             PSF.SaveOrUpdate <TicketSystem>(TicketSystem);
         }
         else
         {
             string ticketNo = "ETicket-" + TicketSystem.Id;
             TicketSystem.TicketNo = ticketNo;
             PSF.Save <TicketSystem>(TicketSystem);
         }
         return(TicketSystem.TicketNo);
     }
     catch (Exception)
     {
         throw;
     }
 }