Exemplo n.º 1
0
        /// <summary>
        /// Active or inactive user by UserId
        /// </summary>
        /// <param name="UserId">Id of the User</param>
        /// <returns>Returns TRUE or FALSE</returns>
        public static bool ActiveInactiveUser(int UserId)
        {
            try
                 {
                     if (UserId <= 0) return false;

                     UserDTO UserDTO = new UserDTO();
                     UserDTO = GetById(UserId);
                     if (UserDTO == null) return false;

                     if (UserDTO.IsActive == true)
                     {
                         UserDTO.IsActive = false;
                         Edit(UserDTO);
                         return true;
                     }
                     else
                     {
                         UserDTO.IsActive = true;
                         Edit(UserDTO);
                         return true;
                     }

                 }
                 catch
                 {
                     throw;
                 }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create User
        /// </summary>
        /// <param name="UserDTO">UserDTO object</param>
        /// <returns>This will return user details</returns>
        public static UserDTO Create(UserDTO UserDTO)
        {
            //if (UserDTO.Mobile == null && UserDTO.Mobile == "")
            //{
            //    return null;
            //}

            GlobalSettings.LoggedInClientId = UserDTO.ClientId;
            int PartnerId = ClientService.GetById(UserDTO.ClientId).PartnerId;
            GlobalSettings.LoggedInPartnerId = PartnerId;

            try
            {
                var User = new User();
                using (var uow = new UnitOfWork())
                {
                    UserDTO.IsActive = true;
                    //UserDTO.UserType = "Admin";
                    User = Transform.UserToDomain(UserDTO);
                    uow.UserRepo.Insert(User);
                    uow.SaveChanges();
                    CommonService.SendEmail("msgBlaster Login details", "Hello " + User.FirstName + ", <br/><br/> <p>Your msgBlaster username and Password is as follows - </p> <br/> <table><tr><td> Username</td><td> = " + User.Email + "</td></tr><tr><td>Password</td><td> = " + User.Password + "</td></tr></table>", User.Email, "", false);

                    if (User.Id > 0)
                    {
                        UserDTO.Id = User.Id;
                        return UserDTO;
                    }
                    else throw new OperationCanceledException("Insert operation terminated");

                }

            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {
                throw;
            }
        }
        //Get reedeemed count by clinet id and campaign id
        public static List<RedeemedCountDTO> GetByClientId(int ClientId, int CampaignId)
        {
            List<RedeemedCountDTO> RedeemedCountDTOList = new List<RedeemedCountDTO>();
            try
            {
                UnitOfWork uow = new UnitOfWork();
                IEnumerable<RedeemedCount> RedeemedCount = uow.RedeemedCountRepo.GetAll().Where(e => e.ClientId == ClientId && e.EcouponCampaignId == CampaignId);
                if (RedeemedCount != null)
                {
                    foreach (var item in RedeemedCount)
                    {
                        EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                        EcouponCampaignDTO = EcouponCampaignService.GetById(item.EcouponCampaignId);
                        if (EcouponCampaignDTO.ExpiresOn > System.DateTime.Now)
                        {

                            RedeemedCountDTO RedeemedCountDTO = new RedeemedCountDTO();
                            RedeemedCountDTO = Transform.RedeemedCountToDTO(item);

                            UserDTO UserDTO = new UserDTO();
                            UserDTO = UserService.GetById(item.UserId);
                            RedeemedCountDTO.UserName = UserDTO.Name;
                            RedeemedCountDTO.Location = LocationService.GetById(UserDTO.LocationId).Name;
                            ClientDTO ClientDTO = new ClientDTO();
                            ClientDTO = ClientService.GetById(ClientId);
                            RedeemedCountDTO.ClientName = ClientDTO.Company;
                            RedeemedCountDTO.CampaignName = EcouponCampaignDTO.Title;
                            RedeemedCountDTOList.Add(RedeemedCountDTO);
                        }
                    }
                }

                return RedeemedCountDTOList;
            }
            catch
            {
                //  throw;
                return RedeemedCountDTOList;
            }
        }
 public void EditUser(string accessId, UserDTO UserDTO)
 {
     try
     {
         UserService.Edit(UserDTO);
     }
     catch (TimeoutException)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout)
         {
             Content = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "Critical Exception"
         });
     }
     catch (Exception)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "Critical Exception"
         });
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///  Send mail to the user after he forgotten his password
 /// </summary>
 /// <param name="Email">Email of the user</param>
 /// <returns>If mail present then mail sent to that mail and returns TRUE for success if FALSE then it will be either inactive or not present</returns>
 public static bool ForgotPassword(string Email)
 {
     try
     {
         UnitOfWork uow = new UnitOfWork();
         UserDTO UserDTO = new UserDTO();
         IEnumerable<User> User = uow.UserRepo.GetAll().Where(e => e.Email.ToLower() == Email.ToLower() && e.IsActive == true);
         if (User.ToList().Count > 0)
         {
             foreach (var item in User)
             {
                 UserDTO = Transform.UserToDTO(item);
             }
             CommonService.SendEmail("msgBlaster Login details", "Hello " + UserDTO.Name + ", <br/><br/> <p>Your msgBlaster username and password is as follows - </p> <br/> <table><tr><td> Username</td><td> = " + UserDTO.Email + "</td></tr><tr><td>Password</td><td> = " + UserDTO.Password + "</td></tr></table>", UserDTO.Email, "", false);
             return true;
         }
         else return false;
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Edit User
        /// </summary>
        /// <param name="UserDTO"> Modify the user as per provided user details </param>
        public static void Edit(UserDTO UserDTO)
        {
            //if (UserDTO.Mobile != null && UserDTO.Mobile != "")
            //{
                try
                {
                    GlobalSettings.LoggedInClientId = UserDTO.ClientId;
                    GlobalSettings.LoggedInUserId = UserDTO.Id;
                    int PartnerId = ClientService.GetById(UserDTO.ClientId).PartnerId;
                    GlobalSettings.LoggedInPartnerId = PartnerId;

                    UserDTO UserDTOOld = new UserDTO();
                    UserDTOOld = GetById(UserDTO.Id);

                    UnitOfWork uow = new UnitOfWork();
                    User User = Transform.UserToDomain(UserDTO);
                    uow.UserRepo.Update(User);
                    uow.SaveChanges();

                    //if (UserDTOOld.Password != UserDTO.Password || UserDTOOld.Email != UserDTO.Email)
                    //{
                    //    CommonService.SendEmail("Your msgBlaster Login details are modified", "Hello " + User.Name + ", <br/><br/> <p>Your latest msgBlaster username and Password is as follows - </p> <br/> <table><tr><td> Username</td><td> = " + User.Email + "</td></tr><tr><td>Password</td><td> = " + User.Password + "</td></tr></table>", User.Email, "", false);
                    //}

                }
                catch
                {
                    throw;
                }
            //}
        }
        //Get credit request list by  client id
        public static List<CreditRequestDTO> GetCreditRequestsbyClientId(int ClientId, string search)
        {
            List<CreditRequestDTO> CreditRequestDTOList = new List<CreditRequestDTO>();
            try
            {
                UnitOfWork uow = new UnitOfWork();
                IEnumerable<CreditRequest> CreditRequest = uow.CreditRequestRepo.GetAll().Where(e => e.ClientId == ClientId).OrderByDescending(e => e.Date).ToList();
                if (CreditRequest != null)
                {
                    if (search != "" & search != null)
                    {

                        bool IsDate = CommonService.IsDate(search);
                        if (IsDate != true)
                        {
                            // string search
                            // var CreditRequestsearch = CreditRequest.Where(e => e.Amount.ToString().Contains(search.ToLower()) || e.ClientId.ToString().Contains(search) || e.GrandTotal.ToString().Contains(search) || e.IsProvided.ToString().Contains(search) || e.OldBalance.ToString().Contains(search) || e.PartnerId.ToString().Contains(search) || e.RatePerSMS.ToString().Contains(search) || e.RequestedCredit.ToString().Contains(search) || e.Tax.ToString().Contains(search));
                            var CreditRequestsearch = CreditRequest.Where(e => e.OldBalance.ToString() == (search) || e.RatePerSMS.ToString() == (search) || e.RequestedCredit.ToString() == (search)).OrderByDescending(e => e.Date);

                            if (CreditRequestsearch != null)
                            {
                                foreach (var item in CreditRequestsearch)
                                {
                                    CreditRequestDTO CreditRequestDTO = new CreditRequestDTO();
                                    CreditRequestDTO = Transform.CreditRequestToDTO(item);

                                    ClientDTO ClientDTO = new ClientDTO();
                                    ClientDTO = ClientService.GetById(item.ClientId);
                                    CreditRequestDTO.ClientName = ClientDTO.Company;

                                    UserDTO UserDTO = new UserDTO();
                                    UserDTO = UserService.GetById(item.RequestedBy);
                                    CreditRequestDTO.UserName = UserDTO.Name;

                                    CreditRequestDTOList.Add(CreditRequestDTO);// (Transform.CreditRequestToDTO(item));
                                }
                            }
                            return CreditRequestDTOList;
                        }
                        else
                        {
                            //date wise search
                            DateTime date = Convert.ToDateTime(search);
                            var CreditRequestsearch = CreditRequest.Where(e => e.Date >= date && e.Date < date.AddDays(1) || e.ProvidedDate >= date && e.ProvidedDate < date.AddDays(1)).OrderByDescending(e => e.Date);

                            if (CreditRequestsearch != null)
                            {
                                foreach (var item in CreditRequestsearch)
                                {
                                    CreditRequestDTO CreditRequestDTO = new CreditRequestDTO();
                                    CreditRequestDTO = Transform.CreditRequestToDTO(item);

                                    ClientDTO ClientDTO = new ClientDTO();
                                    ClientDTO = ClientService.GetById(item.ClientId);
                                    CreditRequestDTO.ClientName = ClientDTO.Company;

                                    UserDTO UserDTO = new UserDTO();
                                    UserDTO = UserService.GetById(item.RequestedBy);
                                    CreditRequestDTO.UserName = UserDTO.Name;

                                    CreditRequestDTOList.Add(CreditRequestDTO);// (Transform.CreditRequestToDTO(item));
                                }
                            }
                            return CreditRequestDTOList;
                        }

                    }
                    else
                    {
                        foreach (var item in CreditRequest)
                        {
                            CreditRequestDTO CreditRequestDTO = new CreditRequestDTO();
                            CreditRequestDTO = Transform.CreditRequestToDTO(item);

                            ClientDTO ClientDTO = new ClientDTO();
                            ClientDTO = ClientService.GetById(item.ClientId);
                            CreditRequestDTO.ClientName = ClientDTO.Company;

                            UserDTO UserDTO = new UserDTO();
                            UserDTO = UserService.GetById(item.RequestedBy);
                            CreditRequestDTO.UserName = UserDTO.Name;

                            CreditRequestDTOList.Add(CreditRequestDTO);// (Transform.CreditRequestToDTO(item));
                        }
                    }
                }

                return CreditRequestDTOList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        //Return Coupon redeemed list as per client
        public static List<CouponDTO> GetCouponListByClientIdWithRedeem(int ClientId)
        {
            List<CouponDTO> CouponDTOList = new List<CouponDTO>();

            try
            {

                using (var uow = new UnitOfWork())
                {
                    IEnumerable<EcouponCampaign> EcouponCampaign = uow.EcouponCampaignRepo.GetAll().Where(e => e.ClientId == ClientId);
                    //var EcouponCampaigncoupons = from c in EcouponCampaign where (from g in c.Coupons where c.ClientId == ClientId  select g).Any() select c;

                    if (EcouponCampaign != null)
                    {
                        foreach (var item in EcouponCampaign)
                        {
                            IEnumerable<Coupon> Coupon = uow.CouponRepo.GetAll().Where(e => e.EcouponCampaignId == item.Id && e.IsRedeem == true);
                            if (Coupon != null)
                            {
                                foreach (var itemCoupon in Coupon)
                                {
                                    CouponDTO CouponDTO = new CouponDTO();
                                    if (itemCoupon.EcouponCampaignId == item.Id)
                                    {
                                        UserDTO UserDTO = new UserDTO();
                                        CouponDTO = Transform.CouponToDTO(itemCoupon);
                                        if (CouponDTO.UserId != null)
                                        {
                                            int UserId = (int)CouponDTO.UserId;
                                            UserDTO = UserService.GetById(UserId);
                                            CouponDTO.UserName = UserDTO.Name;
                                        }
                                        else { CouponDTO.UserName = ""; }
                                        CouponDTOList.Add(CouponDTO);
                                        // CouponDTOList.Add(Transform.CouponToDTO(itemCoupon));
                                    }
                                }
                            }
                        }

                    }
                }

                return CouponDTOList;
            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
Exemplo n.º 9
0
        //GetClientUserByEmailAndPassword
        /// <summary>
        /// Sign In user
        /// </summary>
        /// <param name="Email">Email Id of active user</param>
        /// <param name="Password">Password of the active user</param>
        /// <returns></returns>             
        public static UserDTO SignIn(string Email, string Password)
        {
            try
            {
                UserDTO UserDTO = new UserDTO();
                List<UserDTO> UserDTOList = new List<UserDTO>();

                UnitOfWork uow = new UnitOfWork();
                IEnumerable<User> User = uow.UserRepo.GetAll().Where(e => e.Email.ToLower() == Email.ToLower() && e.Password == Password && e.IsActive == true);
                if (User != null)
                {
                    foreach (var item in User)
                    {
                        //ClientDTOList.Add(Transform.ClientToDTO(item));
                        UserDTO = Transform.UserToDTO(item);
                        GlobalSettings.LoggedInUserId = UserDTO.Id;
                        UserDTO.UserAccessPrivileges = GetUserAccess(UserDTO.UserType.ToString());
                        // Check Client is Active or not
                        ClientDTO ClientDTO = new ClientDTO();
                        ClientDTO = ClientService.GetById(UserDTO.ClientId);
                        GlobalSettings.LoggedInClientId = ClientDTO.Id;

                        if (ClientDTO.IsActive != true)
                        {
                            UserDTO = null;
                        }
                        //HttpContext.Current.Session["LoggedClient"] = ClientDTO;
                        //HttpContext.Current.Session["LoggedClientId"] = ClientDTO.Id;

                    }
                }
                return UserDTO;
            }
            catch
            {
                throw;
            }
        }
        //Generate bill by credit request details
        public static CreditRequestDTO GenerateBill(CreditRequestDTO CreditRequestDTO)
        {
            CreditRequestDTO CreditRequestDTONew = new CreditRequestDTO();
            try
            {
                //if (CreditRequestDTO.Tax == null)
                //{
                //    CreditRequestDTO.Tax = 0;
                //}

                if (CreditRequestDTO.IsProvided == true)
                {
                    CreditRequestDTONew = CreditRequestDTO;
                    CreditRequestDTONew.IsBillGenerated = true;
                    CreditRequestDTONew.IsProvided = true;
                    //CreditRequestDTONew.ProvidedDate = System.DateTime.Now;
                    CreditRequestDTONew.RatePerSMS = CreditRequestDTO.RatePerSMS;
                    CreditRequestDTONew.Tax = CreditRequestDTO.Tax;
                    CreditRequestDTONew.ProvidedCredit = CreditRequestDTO.ProvidedCredit;
                    CreditRequestDTONew.Amount = CreditRequestDTO.ProvidedCredit * CreditRequestDTO.RatePerSMS;
                    double tax = (CreditRequestDTONew.Amount * Convert.ToDouble(CreditRequestDTONew.Tax)) / 100;
                    CreditRequestDTONew.TaxAmount = tax;
                    CreditRequestDTONew.GrandTotal = CreditRequestDTONew.Amount + tax;

                    //if (CreditRequestDTO.GrandTotal != CreditRequestDTONew.GrandTotal)
                    //{
                    //    CreditRequestDTONew.GrandTotal = CreditRequestDTO.GrandTotal;
                    //}

                    GlobalSettings.LoggedInClientId = CreditRequestDTO.ClientId;
                    GlobalSettings.LoggedInUserId = CreditRequestDTO.RequestedBy;
                    int PartnerId = ClientService.GetById(CreditRequestDTO.ClientId).PartnerId;
                    GlobalSettings.LoggedInPartnerId = PartnerId;

                    UnitOfWork uow = new UnitOfWork();
                    CreditRequest CreditRequest = Transform.CreditRequestToDomain(CreditRequestDTONew);
                    uow.CreditRequestRepo.Update(CreditRequest);
                    uow.SaveChanges();

                    ClientDTO ClientDTO = new ClientDTO();
                    ClientDTO = ClientService.GetById(CreditRequest.ClientId);

                    UserDTO UserDTO = new UserDTO();
                    UserDTO = UserService.GetById(CreditRequest.RequestedBy);

                    DateTime date = (DateTime)CreditRequestDTONew.ProvidedDate;
                    string DateFormat = date.ToString("dd-MMM-yyyy HH:mm");

                    CommonService.SendEmail("msgBlaster Bill", "<html><body><p>Hello " + ClientDTO.Company + ",</p> <br/><p>Your mesgblaster bill details are as follows.<p/> <table><tr><td> Date</td> <td> " + DateFormat + " </td> </tr>  <tr><td> Provided Credits</td> <td> " + CreditRequest.ProvidedCredit + " </td> </tr> <td> Total Balance</td> <td> " + ClientDTO.SMSCredit + " </td> </tr> <tr><td> Rate Per SMS</td> <td> " + String.Format("{0:0.00}", CreditRequest.RatePerSMS) + " </td> </tr> <tr><td> Amount </td> <td> " + String.Format("{0:0.00}", CreditRequest.Amount) + " </td> </tr> <tr><td> Tax</td> <td> " + String.Format("{0:0.00}", CreditRequest.Tax) + "% </td> </tr> <tr><td> <strong>Grand Total</strong></td> <td> <strong>" + String.Format("{0:0.00}", CreditRequest.GrandTotal) + "</strong> </td> </tr>  </table>  </body></html>", UserDTO.Email, "", false);  //<tr><td> Provided Credits</td> <td> " + CreditRequest.ProvidedCredit + " </td> </tr> <tr><td> Rate Per SMS</td> <td> " + CreditRequest.RatePerSMS + " </td> </tr> <tr><td> Amount </td> <td> " + CreditRequest.Amount + " </td> </tr> <tr><td> Tax</td> <td> " + CreditRequest.Tax + " </td> </tr> <tr><td> <strong>Grand Total</strong></td> <td> <strong>" + CreditRequest.GrandTotal + "</strong> </td> </tr>

                    CreditRequestDTONew = Transform.CreditRequestToDTO(CreditRequest);
                    return CreditRequestDTONew;
                }
                else
                {
                    return CreditRequestDTO;
                }

            }
            catch (Exception)
            {
                //return CreditRequestDTO;
                throw;
            }
        }
        //Send bill to client by credit request id
        public static bool SendBillToClient(int CreditRequestId)
        {
            bool IsSend = false;

            CreditRequestDTO CreditRequestDTO = new CreditRequestDTO();
            CreditRequestDTO = GetById(CreditRequestId);
            if (CreditRequestDTO.ProvidedDate != null)
            {
                ClientDTO ClientDTO = new ClientDTO();
                ClientDTO = ClientService.GetById(CreditRequestDTO.ClientId);

                UserDTO UserDTO = new UserDTO();
                UserDTO = UserService.GetById(CreditRequestDTO.RequestedBy);

                DateTime date = (DateTime)CreditRequestDTO.ProvidedDate;
                string DateFormat = date.ToString("dd-MMM-yyyy HH:mm");

                IsSend = CommonService.SendEmail("msgBlaster SMS credit provided bill", "<html><body><p>Hello " + ClientDTO.Company + ",</p> <br/><p>Your mesgblaster Bill details are as follows.<p/> <table><tr><td> Bill Date</td> <td> " + DateFormat + " </td> </tr> <tr><td> Requested Credits</td> <td> " + CreditRequestDTO.RequestedCredit + " </td> </tr> <tr><td> Provided Credits</td> <td> " + CreditRequestDTO.ProvidedCredit + " </td> </tr> <tr><td> Rate Per SMS</td> <td> " + String.Format("{0:0.00}", CreditRequestDTO.RatePerSMS) + " </td> </tr> <tr><td> Amount </td> <td> " + String.Format("{0:0.00}", CreditRequestDTO.Amount) + " </td> </tr><tr><td> Tax</td> <td> " + String.Format("{0:0.00}", CreditRequestDTO.Tax) + "% </td> </tr> <tr><td> <strong>Grand Total</strong></td> <td> <strong>" + String.Format("{0:0.00}", CreditRequestDTO.GrandTotal) + "</strong> </td> </tr>  </table>  </body></html>", UserDTO.Email, "", false);
                IsSend = true;
            }
            else { IsSend = false; }
            return IsSend;
        }
Exemplo n.º 12
0
 public static User UserToDomain(UserDTO UserDTO)
 {
     if (UserDTO == null) return null;
      Mapper.CreateMap<UserDTO,User>();
      User User = Mapper.Map<User>(UserDTO);
      return User;
 }
Exemplo n.º 13
0
        //Return Coupon list as per partner id
        public static List<CouponDTO> GetCouponListSearchByPartnerId(int PartnerId, string search)
        {
            List<EcouponCampaignDTO> EcouponCampaignDTOList = new List<EcouponCampaignDTO>();
            List<CouponDTO> CouponDTOList = new List<CouponDTO>();
            try
            {
                EcouponCampaignDTOList = EcouponCampaignService.GetEcouponCampaignListSearchByPartnerId(PartnerId, "");

                if (EcouponCampaignDTOList.Count > 0)
                {
                    foreach (var item in EcouponCampaignDTOList)
                    {
                        var EcouponCampaign = CouponDTOList.Where(e => e.ClientId == item.ClientId).OrderByDescending(e => e.SentDateTime);// uow.EcouponCampaignRepo.GetAll().Where(e => e.ClientId == ClientId);
                        if (EcouponCampaign != null)
                        {

                            foreach (var itemEcouponCampaign in EcouponCampaign)
                            {
                                CouponDTO CouponDTONew = new CouponDTO();
                                CouponDTONew = itemEcouponCampaign;
                                UserDTO UserDTO = new UserDTO();

                                EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                                EcouponCampaignDTO = EcouponCampaignService.GetById(itemEcouponCampaign.EcouponCampaignId);
                                CouponDTONew.CouponCampaignName = EcouponCampaignDTO.Title;

                                if (itemEcouponCampaign.UserId != null)
                                {
                                    int UserId = (int)itemEcouponCampaign.UserId;
                                    UserDTO = UserService.GetById(UserId);
                                    CouponDTONew.UserName = UserDTO.Name;
                                }
                                else
                                {
                                    CouponDTONew.UserName = "";
                                }

                                CouponDTOList.Add(CouponDTONew);
                            }
                        }
                    }
                }

                if (search != "" && search != null)
                {
                    bool Isdate = CommonService.IsDate(search);
                    if (Isdate != true)
                    {
                        List<CouponDTO> CouponDTOSearchList = new List<CouponDTO>();
                        var CouponSearch = CouponDTOList.Where(e => e.Code.Contains(search) || (e.MobileNumber != null ? (e.MobileNumber.Contains(search)) : false) || (e.Remark != null ? (e.Remark.ToLower().Contains(search.ToLower())) : false) || e.UserName.ToLower().Contains(search.ToLower()) || (e.RedeemDateTime.ToString() != null ? (Convert.ToDateTime(e.RedeemDateTime).ToString("dd-MMM-yyyy").ToLower().Contains(search.ToLower())) : false) || (e.CouponCampaignName != null ? (e.CouponCampaignName.ToLower().Contains(search.ToLower())) : false)).OrderByDescending(e => e.SentDateTime);
                        if (CouponSearch != null)
                        {
                            foreach (var itemsearch in CouponSearch)
                            {

                                CouponDTOSearchList.Add(itemsearch);
                            }
                        }
                        return CouponDTOSearchList;

                    }
                    else
                    {
                        List<CouponDTO> CouponDTOSearchList = new List<CouponDTO>();
                        DateTime date = Convert.ToDateTime(search);
                        var CouponSearch = CouponDTOList.Where(e => e.RedeemDateTime >= date && e.RedeemDateTime < date.AddDays(1)).OrderByDescending(e => e.SentDateTime);
                        if (CouponSearch != null)
                        {
                            foreach (var itemsearch in CouponSearch)
                            {

                                CouponDTOSearchList.Add(itemsearch);
                            }
                        }
                        return CouponDTOSearchList;
                    }
                }
                return CouponDTOList;
            }

              //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
Exemplo n.º 14
0
        //Return Coupon list as per Ecoupon campaign id and Is sent status
        public static List<CouponDTO> GetCouponListSearchByEcouponCampaignId(int EcouponCampaignId, string search, bool IsSent, PagingInfo pagingInfo)
        {
            List<CouponDTO> CouponDTOList = new List<CouponDTO>();
            try
            {
                using (var uow = new UnitOfWork())
                {
                    IEnumerable<EcouponCampaign> EcouponCampaign = uow.EcouponCampaignRepo.GetAll().Where(e => e.Id == EcouponCampaignId && e.IsSent == IsSent).OrderByDescending(e => e.CreatedDate);
                    //var EcouponCampaigncoupons = from c in EcouponCampaign where (from g in c.Coupons where c.ClientId == ClientId  select g).Any() select c;
                    int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                    int take = pagingInfo.ItemsPerPage;

                    if (EcouponCampaign != null)
                    {
                        foreach (var item in EcouponCampaign)
                        {
                            IQueryable<Coupon> Coupon = uow.CouponRepo.GetAll().Where(e => e.EcouponCampaignId == item.Id).AsQueryable();//.OrderByDescending(e => e.SentDateTime).Skip(skip).Take(take);
                            Coupon = PagingService.Sorting<Coupon>(Coupon, pagingInfo.SortBy, pagingInfo.Reverse);
                            Coupon = Coupon.Skip(skip).Take(take);

                            if (Coupon != null)
                            {
                                foreach (var itemCoupon in Coupon)
                                {
                                    CouponDTO CouponDTO = new CouponDTO();
                                    if (itemCoupon.EcouponCampaignId == item.Id)
                                    {
                                        UserDTO UserDTO = new UserDTO();
                                        CouponDTO = Transform.CouponToDTO(itemCoupon);

                                        EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                                        EcouponCampaignDTO = EcouponCampaignService.GetById(itemCoupon.EcouponCampaignId);
                                        CouponDTO.CouponCampaignName = EcouponCampaignDTO.Title;
                                        CouponDTO.MinPurchaseAmount = EcouponCampaignDTO.MinPurchaseAmount;

                                        if (CouponDTO.UserId != null)
                                        {
                                            int UserId = (int)CouponDTO.UserId;
                                            UserDTO = UserService.GetById(UserId);
                                            CouponDTO.UserName = UserDTO.Name;
                                        }
                                        else
                                        {
                                            CouponDTO.UserName = "";
                                        }

                                        CouponDTOList.Add(CouponDTO);
                                        //CouponDTOList.Add(Transform.CouponToDTO(itemCoupon));
                                    }
                                }
                            }
                        }
                        if (search != "" & search != null)
                        {
                            EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                            EcouponCampaignDTO = EcouponCampaignService.GetById(EcouponCampaignId);
                            //int UserId = 0;
                            //UserId = UserService.GetUserByName(search,EcouponCampaignDTO.ClientId);
                            int CampaignId = 0;

                            string UserIdString = UserService.GetUserIdarrayByName(search, EcouponCampaignDTO.ClientId);

                            CampaignId = EcouponCampaignService.GetEcouponCampaignByName(search, EcouponCampaignDTO.ClientId);

                            bool Isdate = CommonService.IsDate(search);
                            if (Isdate != true)
                            {
                                List<CouponDTO> CouponDTOSearchList = new List<CouponDTO>();
                                IQueryable<Coupon> CouponSearch = uow.CouponRepo.GetAll().Where(e => (e.Code.Contains(search) || (e.MobileNumber != null ? (e.MobileNumber.Contains(search)) : false) || (e.Remark != null ? (e.Remark.ToLower().Contains(search.ToLower())) : false) || (e.RedeemDateTime.ToString() != null ? (Convert.ToDateTime(e.RedeemDateTime).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (UserIdString != null ? (e.UserId.ToString().Split(',').Any(UserId => UserIdString.Contains(UserId))) : false) || (e.EcouponCampaignId != 0 ? (e.EcouponCampaignId == CampaignId) : false) || (e.BillNumber != null ? (e.BillNumber.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BillDate.ToString() != null ? (Convert.ToDateTime(e.BillDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)) && e.EcouponCampaignId == EcouponCampaignId).AsQueryable();//.OrderByDescending(e => e.SentDateTime).Skip(skip).Take(take); //|| e.UserName.ToLower().Contains(search.ToLower()) || (e.CouponCampaignName != null ? (e.CouponCampaignName.ToLower().Contains(search.ToLower())) : false)

                                CouponSearch = PagingService.Sorting<Coupon>(CouponSearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                CouponSearch = CouponSearch.Skip(skip).Take(take);

                                if (CouponSearch != null)
                                {
                                    foreach (var itemsearch in CouponSearch)
                                    {
                                        if (itemsearch.EcouponCampaignId == EcouponCampaignId)
                                        {
                                            CouponDTO CouponDTO = new CouponDTO();
                                            CouponDTO = Transform.CouponToDTO(itemsearch);

                                            EcouponCampaignDTO EcouponCampaignDTOSearch = new EcouponCampaignDTO();
                                            EcouponCampaignDTOSearch = EcouponCampaignService.GetById(itemsearch.EcouponCampaignId);
                                            CouponDTO.CouponCampaignName = EcouponCampaignDTOSearch.Title;
                                            CouponDTO.MinPurchaseAmount = EcouponCampaignDTOSearch.MinPurchaseAmount;

                                            UserDTO UserDTO = new UserDTO();
                                            if (itemsearch.UserId == null)
                                            { itemsearch.UserId = 0; }
                                            int userId = (int)itemsearch.UserId;
                                            if (userId != 0)
                                            {
                                                UserDTO = UserService.GetById(userId);
                                                CouponDTO.UserName = UserDTO.Name;
                                            }
                                            CouponDTOSearchList.Add(CouponDTO);
                                        }
                                    }
                                }
                                return CouponDTOSearchList;

                            }
                            else
                            {
                                List<CouponDTO> CouponDTOSearchList = new List<CouponDTO>();
                                DateTime date = Convert.ToDateTime(search);
                                IQueryable<Coupon> CouponSearch = uow.CouponRepo.GetAll().Where(e => (e.RedeemDateTime >= date && e.RedeemDateTime < date.AddDays(1) && e.BillDate >= date && e.BillDate < date.AddDays(1)) && e.EcouponCampaignId == EcouponCampaignId).AsQueryable();//.OrderByDescending(e => e.SentDateTime).Skip(skip).Take(take);
                                CouponSearch = PagingService.Sorting<Coupon>(CouponSearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                CouponSearch = CouponSearch.Skip(skip).Take(take);

                                if (CouponSearch != null)
                                {
                                    foreach (var itemsearch in CouponSearch)
                                    {
                                        if (itemsearch.EcouponCampaignId == EcouponCampaignId)
                                        {
                                            CouponDTO CouponDTO = new CouponDTO();
                                            CouponDTO = Transform.CouponToDTO(itemsearch);
                                            UserDTO UserDTO = new UserDTO();

                                            EcouponCampaignDTO EcouponCampaignDTOSearch = new EcouponCampaignDTO();
                                            EcouponCampaignDTOSearch = EcouponCampaignService.GetById(itemsearch.EcouponCampaignId);
                                            CouponDTO.CouponCampaignName = EcouponCampaignDTOSearch.Title;
                                            CouponDTO.MinPurchaseAmount = EcouponCampaignDTOSearch.MinPurchaseAmount;

                                            if (itemsearch.UserId == null)
                                            { itemsearch.UserId = 0; }

                                            int userId = (int)itemsearch.UserId;
                                            if (userId != 0)
                                            {
                                                UserDTO = UserService.GetById(userId);
                                                CouponDTO.UserName = UserDTO.Name;
                                            }
                                            CouponDTOSearchList.Add(CouponDTO);
                                        }

                                        //CouponDTOSearchList.Add(Transform.CouponToDTO(itemsearch));
                                    }
                                }
                                return CouponDTOSearchList;

                            }

                        }

                    }

                }

                return CouponDTOList;
            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
Exemplo n.º 15
0
        //Return Coupon list as per user id
        public static List<CouponDTO> GetCouponListByUserId(int UserId, PagingInfo pagingInfo)
        {
            List<CouponDTO> CouponDTOList = new List<CouponDTO>();
            try
            {
                UserDTO UserDTO = new UserDTO();
                UserDTO = UserService.GetById(UserId);

                using (var uow = new UnitOfWork())
                {
                    int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                    int take = pagingInfo.ItemsPerPage;

                    IQueryable<Coupon> Coupon = uow.CouponRepo.GetAll().Where(e => e.UserId == UserId && e.IsExpired != true && e.IsRedeem == true).AsQueryable(); //.OrderByDescending(e => e.SentDateTime);
                    Coupon = PagingService.Sorting<Coupon>(Coupon, pagingInfo.SortBy, pagingInfo.Reverse);
                    Coupon = Coupon.Skip(skip).Take(take);

                    if (Coupon != null)
                    {
                        foreach (var item in Coupon)
                        {

                            CouponDTO CouponDTO = new CouponDTO();
                            CouponDTO = Transform.CouponToDTO(item);
                            CouponDTO.UserName = UserDTO.Name;

                            EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                            EcouponCampaignDTO = EcouponCampaignService.GetById(CouponDTO.EcouponCampaignId);
                            CouponDTO.CouponCampaignName = EcouponCampaignDTO.Title;
                            CouponDTO.ExpiresOn = EcouponCampaignDTO.ExpiresOn;
                            CouponDTO.MinPurchaseAmount = EcouponCampaignDTO.MinPurchaseAmount;

                            CouponDTOList.Add(CouponDTO);// (Transform.CouponToDTO(item));
                        }
                    }

                    if (pagingInfo.Search != "" && pagingInfo.Search != null)
                    {

                        bool Isdate = CommonService.IsDate(pagingInfo.Search);
                        if (Isdate != true)
                        {

                            IQueryable<CouponDTO> CouponList = CouponDTOList.Where(e => e.CouponCampaignName.ToLower().Contains(pagingInfo.Search.ToLower()) || (e.MobileNumber != null ? (e.MobileNumber.Contains(pagingInfo.Search)) : false) || (e.Amount != null ? (e.Amount.ToString() == pagingInfo.Search.ToString()) : false) || (e.Code != null ? (e.Code.Contains(pagingInfo.Search)) : false) || (e.Message != null ? (e.Message.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.RedeemDateTime.ToString() != null ? (Convert.ToDateTime(e.RedeemDateTime).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.Remark != null ? (e.Remark.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BillNumber != null ? (e.BillNumber.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BillDate.ToString() != null ? (Convert.ToDateTime(e.BillDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable();//.OrderByDescending(e => e.SentDateTime).ToList();
                            CouponList = PagingService.Sorting<CouponDTO>(CouponList, pagingInfo.SortBy, pagingInfo.Reverse);
                            CouponList = CouponList.Skip(skip).Take(take);

                            List<CouponDTO> CouponDTOListNew = new List<CouponDTO>();
                            if (CouponDTOList.Count > 0)
                            {
                                foreach (var item in CouponList)
                                {
                                    EcouponCampaignDTO EcouponCampaignDTOSearch = new EcouponCampaignDTO();
                                    EcouponCampaignDTOSearch = EcouponCampaignService.GetById(item.EcouponCampaignId);
                                    item.CouponCampaignName = EcouponCampaignDTOSearch.Title;
                                    item.ExpiresOn = EcouponCampaignDTOSearch.ExpiresOn;
                                    item.MinPurchaseAmount = EcouponCampaignDTOSearch.MinPurchaseAmount;

                                    CouponDTOListNew.Add(item);
                                }
                                return CouponDTOListNew;
                            }

                        }
                        else
                        {
                            List<CouponDTO> CouponDTOListNew = new List<CouponDTO>();
                            DateTime date = Convert.ToDateTime(pagingInfo.Search);
                            IQueryable<CouponDTO> CouponList = CouponDTOList.Where(e => e.RedeemDateTime >= date && e.RedeemDateTime < date.AddDays(1) && e.BillDate >= date && e.BillDate < date.AddDays(1)).AsQueryable();//.OrderByDescending(e => e.SentDateTime).ToList();
                            CouponList = PagingService.Sorting<CouponDTO>(CouponList, pagingInfo.SortBy, pagingInfo.Reverse);
                            CouponList = CouponList.Skip(skip).Take(take);
                            if (CouponDTOList.Count > 0)
                            {
                                foreach (var item in CouponList)
                                {
                                    EcouponCampaignDTO EcouponCampaignDTOSearch = new EcouponCampaignDTO();
                                    EcouponCampaignDTOSearch = EcouponCampaignService.GetById(item.EcouponCampaignId);
                                    item.CouponCampaignName = EcouponCampaignDTOSearch.Title;
                                    item.ExpiresOn = EcouponCampaignDTOSearch.ExpiresOn;
                                    item.MinPurchaseAmount = EcouponCampaignDTOSearch.MinPurchaseAmount;

                                    CouponDTOListNew.Add(item);
                                }
                                return CouponDTOListNew;
                            }
                        }

                    }

                }

                return CouponDTOList;
            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
        //Create credit request
        public static CreditRequestDTO Create(CreditRequestDTO CreditRequestDTO)
        {
            try
            {
                CreditRequestDTO CreditRequestDTONew = new CreditRequestDTO();

                PartnerDTO PartnerDTO = new PartnerDTO();
                ClientDTO ClientDTO = new ClientDTO();
                UserDTO UserDTO = new UserDTO();

                PartnerDTO = PartnerService.GetById(CreditRequestDTO.PartnerId);
                ClientDTO = ClientService.GetById(CreditRequestDTO.ClientId);
                UserDTO = UserService.GetById(CreditRequestDTO.RequestedBy);

                GlobalSettings.LoggedInClientId = ClientDTO.Id;
                GlobalSettings.LoggedInUserId = UserDTO.Id;
                int PartnerId = PartnerDTO.Id;
                GlobalSettings.LoggedInPartnerId = PartnerId;

                if (CreditRequestDTO.RequestedCredit <= 0)
                {
                    return null; //0
                }
                var CreditRequest = new CreditRequest();
                using (var uow = new UnitOfWork())
                {
                    CreditRequest = Transform.CreditRequestToDomain(CreditRequestDTO);
                    CreditRequest.Date = System.DateTime.Now;
                    CreditRequest.OldBalance = ClientDTO.SMSCredit;
                    CreditRequest.IsProvided = false;
                    //CreditRequest.ProvidedCredit = CreditRequest.RequestedCredit;
                    CreditRequest.Amount = CreditRequest.RequestedCredit * CreditRequest.RatePerSMS;
                    double tax = (CreditRequest.Amount * Convert.ToDouble(CreditRequest.Tax)) / 100;
                    CreditRequest.TaxAmount = tax;
                    CreditRequest.GrandTotal = CreditRequest.Amount + tax;

                    bool IsOnlinepaymentSuccess = Onlinepayment(CreditRequest.GrandTotal);

                    if (IsOnlinepaymentSuccess == true)
                    {
                        //CreditRequest.IsPaymentSuccessful = true;
                        //CreditRequest.PaymentDate = System.DateTime.Now;
                        CreditRequest.ProvidedDate = System.DateTime.Now;
                        CreditRequest.IsProvided = true;
                        CreditRequest.IsBillGenerated = true;
                        CreditRequest.PaymentMode = PaymentMode.Card;
                        CreditRequest.PaymentDate = System.DateTime.Now;
                        CreditRequest.IsPaid = true;
                        CreditRequest.ProvidedCredit = CreditRequest.RequestedCredit;

                        uow.CreditRequestRepo.Insert(CreditRequest);
                        uow.SaveChanges();

                        ClientDTO.SMSCredit = ClientDTO.SMSCredit + CreditRequest.RequestedCredit;
                        ClientService.Edit(ClientDTO);

                    }
                    else
                    {
                        //CreditRequest.IsPaymentSuccessful = false;
                        CreditRequest.IsPaid = false;
                        uow.CreditRequestRepo.Insert(CreditRequest);
                        uow.SaveChanges();
                    }

                    //Update TotalAppliedCredit
                    ClientDTO.TotalAppliedCredit = ClientDTO.TotalAppliedCredit + CreditRequest.RequestedCredit;
                    ClientService.Edit(ClientDTO);

                    //Generate Link to provide mail trhough mail
                    string APILink = ConfigurationManager.AppSettings["APILink"].ToString() + "api/CreditRequest/ProvideCreditByMailLink?CreditRequestId=" + CreditRequest.Id;

                    // Send Email To Partner
                    bool IsMailSent = CommonService.SendEmail("SMS Credit Request", "Hello " + PartnerDTO.Name + ", <br/><br/> The New request of " + CreditRequest.RequestedCredit + " credits applied by " + ClientDTO.Company + "<br/><br/> <a href=" + APILink + ">Approve</a>", PartnerDTO.Email, "", false);

                    CreditRequestDTONew = GetById(CreditRequest.Id);
                    if (CreditRequest.PaymentMode == PaymentMode.Card)
                    {
                        CreditRequestDTONew.OnlinePaymentURL = OnlinePaymentLinkWithTemperproofData(UserDTO.Email, CreditRequest.GrandTotal, UserDTO.Mobile, UserDTO.Name, CreditRequest.Id);
                    }
                    return (CreditRequestDTONew); //.Id);

                }

            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Get active or inactive Users by Client id 
        /// </summary>
        /// <param name="ClientId">Id of the Client</param>
        /// <param name="search">search string</param>
        /// <param name="IsActive">TRUE OR FALSE</param>
        /// <param name="pagingInfo">pagingInfo object</param>
        /// <returns> Returns Active or Inactive user list </returns>
        public static List<UserDTO> GetUsersbyClientIdWithIsActive(int ClientId, string search, bool IsActive, PagingInfo pagingInfo)
        {
            List<UserDTO> UserDTOList = new List<UserDTO>();
            try
            {
                UnitOfWork uow = new UnitOfWork();

                int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int take = pagingInfo.ItemsPerPage;

                IQueryable<User> User = uow.UserRepo.GetAll().Where(e => e.ClientId == ClientId && e.IsActive == IsActive).OrderBy(e => e.Name).AsQueryable();// .ToList().Skip(skip).Take(take);
                User = PagingService.Sorting<User>(User, pagingInfo.SortBy, pagingInfo.Reverse);
                User = User.Skip(skip).Take(take);

                if (User != null)
                {
                    foreach (var user in User)
                    {
                        UserDTO UserDTO = new UserDTO();
                        UserDTO = Transform.UserToDTO(user);
                        LocationDTO LocationDTO = new LocationDTO();
                        UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name;
                        UserDTOList.Add(UserDTO);
                    }

                    if (search != "" && search != null)
                    {
                        //int LocationId = LocationService.GetByLocationName(search, ClientId);
                        string LocationIdString = LocationService.GetLocationIdarrayByName(search, ClientId);

                        bool IsDate = CommonService.IsDate(search);
                        if (IsDate != true)
                        {
                            // string search
                            List<UserDTO> UserDTOListSearch = new List<UserDTO>();
                            IQueryable<User> UserSearch = uow.UserRepo.GetAll().Where(e => (e.Email.ToLower().Contains(search.ToLower()) || e.Name.ToLower().Contains(search.ToLower()) || e.FirstName.ToLower().Contains(search.ToLower()) || e.LastName.ToLower().Contains(search.ToLower()) || (e.Mobile != null ? (e.Mobile.Contains(search)) : false) || (LocationIdString != null ? (e.LocationId.ToString().Split(',').Any(LocationId => LocationIdString.Contains(LocationId.ToString()))) : false)) && e.IsActive == IsActive && e.ClientId == ClientId).AsQueryable();//.OrderBy(e => e.Name).ToList().Skip(skip).Take(take); //(e.Location != null ? (e.Location.ToLower().Contains(search.ToLower())) : false)
                            UserSearch = PagingService.Sorting<User>(UserSearch, pagingInfo.SortBy, pagingInfo.Reverse);
                            UserSearch = UserSearch.Skip(skip).Take(take);

                            foreach (var user in UserSearch)
                            {
                                UserDTO UserDTO = new UserDTO();
                                UserDTO = Transform.UserToDTO(user);
                                LocationDTO LocationDTO = new LocationDTO();
                                UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name;
                                UserDTOListSearch.Add(UserDTO);
                            }
                            return UserDTOListSearch;

                        }
                        else
                        {

                        }

                    }
                    ////else
                    ////{
                    ////    ////foreach (var item in User)
                    ////    ////{
                    ////    ////    //UserDTO UserDTO = new UserDTO();
                    ////    ////    UserDTOList.Add(Transform.UserToDTO(item));
                    ////    ////}
                    ////}
                }

                return UserDTOList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        //Get credit request by id
        public static CreditRequestDTO GetById(int Id)
        {
            try
            {
                UnitOfWork uow = new UnitOfWork();
                CreditRequest CreditRequest = uow.CreditRequestRepo.GetById(Id);
                CreditRequestDTO CreditRequestDTO = Transform.CreditRequestToDTO(CreditRequest);

                ClientDTO ClientDTO = new ClientDTO();
                ClientDTO = ClientService.GetById(CreditRequestDTO.ClientId);
                CreditRequestDTO.ClientName = ClientDTO.Company;

                UserDTO UserDTO = new UserDTO();
                UserDTO = UserService.GetById(CreditRequestDTO.RequestedBy);
                CreditRequestDTO.UserName = UserDTO.Name;

                return CreditRequestDTO;
            }
            catch
            {
                throw;
            }
        }
        //Get document list by client id
        public static List<DocumentDTO> GetDocumentListByClientId(int ClientId)
        {
            List<DocumentDTO> DocumentDTOList = new List<DocumentDTO>();

            try
            {

                using (var uow = new UnitOfWork())
                {
                    IEnumerable<Document> Document = uow.DocumentRepo.GetAll().Where(e => e.ClientId == ClientId);
                    if (Document != null)
                    {
                        foreach (var item in Document)
                        {
                            DocumentDTO DocumentDTO = new DocumentDTO();
                            DocumentDTO = Transform.DocumentToDTO(item);
                            UserDTO UserDTO = new UserDTO();
                            UserDTO = UserService.GetById(DocumentDTO.UserId);
                            DocumentDTO.User = UserDTO.Name;

                            ClientDTO ClientDTO = new ClientDTO();
                            ClientDTO = ClientService.GetById(DocumentDTO.ClientId);
                            DocumentDTO.Client = ClientDTO.Company;

                            DocumentDTOList.Add(DocumentDTO);
                        }
                    }
                }

                return DocumentDTOList;
            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// Register Client
        /// </summary>
        /// <param name="RegisterClientDTO">RegisterClientDTO object</param>
        /// <returns>Register Client details </returns>
        public static RegisterClientDTO RegisterClient(RegisterClientDTO RegisterClientDTO)
        {
            try
            {
                GlobalSettings.LoggedInClientId = null;
                GlobalSettings.LoggedInUserId = null;
                GlobalSettings.LoggedInPartnerId = null;

                RegisterClientDTO.UserType = "Admin";
                RegisterClientDTO RegisterClientDTONew = new RegisterClientDTO();

                ClientDTO ClientDTO = new ClientDTO();
                ClientDTO.Company = RegisterClientDTO.Company;
                ClientDTO.Address = RegisterClientDTO.Address;
                ClientDTO.IsDatabaseUploaded = false;

                ClientDTO ClientDTONew = new ClientDTO();
                ClientDTONew = ClientService.Create(ClientDTO);

                GlobalSettings.LoggedInClientId = ClientDTONew.Id;

                LocationDTO LocationDTO = new LocationDTO();
                LocationDTO.Name = RegisterClientDTO.Location;
                LocationDTO.ClientId = ClientDTONew.Id;
                int LocationId = 0;
                LocationId = LocationService.Create(LocationDTO);

                UserDTO UserDTO = new UserDTO();
                //UserDTO.Name = RegisterClientDTO.Name;
                UserDTO.FirstName = RegisterClientDTO.FirstName;
                UserDTO.LastName = RegisterClientDTO.LastName;
                UserDTO.Email = RegisterClientDTO.Email;
                UserDTO.Password = RegisterClientDTO.Password;
                UserDTO.Mobile = RegisterClientDTO.Mobile;

                UserDTO.LocationId = LocationId;
                UserDTO.ClientId = ClientDTONew.Id;

                UserDTO UserDTONew = new UserDTO();
                UserDTONew = UserService.Create(UserDTO);
                UserDTONew.UserType = "Admin";
                UserDTONew.UserAccessPrivileges = UserService.GetUserAccess(UserDTONew.UserType.ToString());
                GlobalSettings.LoggedInUserId = UserDTONew.Id;

                //Assign client values to Registerclient
                RegisterClientDTONew.Address = ClientDTONew.Address;
                RegisterClientDTONew.ClientId = ClientDTONew.Id;
                RegisterClientDTONew.Company = ClientDTONew.Company;

                //Assign user values to Registerclient
                RegisterClientDTONew.Email = UserDTONew.Email;
                RegisterClientDTONew.Mobile = UserDTONew.Mobile;
                //RegisterClientDTONew.Name = UserDTONew.Name;
                RegisterClientDTONew.FirstName = UserDTONew.FirstName;
                RegisterClientDTONew.LastName = UserDTONew.LastName;
                RegisterClientDTONew.Password = UserDTONew.Password;
                RegisterClientDTONew.Id = UserDTONew.Id;
                RegisterClientDTONew.UserAccessPrivileges = UserDTONew.UserAccessPrivileges;

                return RegisterClientDTONew;

            }
            catch (msgBlasterValidationException)
            {
                throw;
            }
            catch (Exception)
            {
                //HttpContext.Current.Session["LoggedClient"] = null;
                //HttpContext.Current.Session["LoggedClientId"] = "0";
                throw;
            }
        }