public HttpResponseMessage ConfirmUsername([FromBody] PasswordModel changePassword)
 {
     try
     {
         string key      = System.Configuration.ConfigurationManager.AppSettings.Get("ekey");
         string username = Crypter.Decrypt(key, changePassword.Username);
         User   user     = UserPL.RetrieveUserByUsername(username);
         if (user != null)
         {
             //Add a mail for password reset
             object response = new
             {
                 Status   = "Successful",
                 Username = user.Username
             };
             return(Request.CreateResponse(HttpStatusCode.OK, response));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid username"));
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.WriteError(ex);
         var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
         return(response);
     }
 }
 public HttpResponseMessage ForgotPassword([FromBody] PasswordModel changePassword)
 {
     try
     {
         //if (Mail.networkIsAvailable())
         //{
         string username = changePassword.Username;
         User   user     = UserPL.RetrieveUserByUsername(username);
         if (user != null)
         {
             Mail.SendForgotPasswordMail(user);
             return(Request.CreateResponse(HttpStatusCode.OK, user.Email));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid username"));
         }
         //}
         //else
         //{
         //return Request.CreateResponse(HttpStatusCode.BadRequest, "Kindly ensure that internet connection is available in order to reset your password.");
         //}
     }
     catch (Exception ex)
     {
         ErrorHandler.WriteError(ex);
         var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
         return(response);
     }
 }
示例#3
0
 public HttpResponseMessage ForgotPassword([FromBody] PasswordModel changePassword)
 {
     try
     {
         string username = changePassword.Username;
         User   user     = UserPL.RetrieveUserByUsername(username);
         if (user != null)
         {
             Mail.SendForgotPasswordMail(user);
             return(Request.CreateResponse(HttpStatusCode.OK, user.Email));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid username"));
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.WriteError(ex);
         var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
         return(response);
     }
 }
 public long GetCountofRecords(string loggedInUsername)
 {
     try
     {
         var user = UserPL.RetrieveUserByUsername(loggedInUsername);
         if (user == null)
         {
             throw new Exception("Invalid User Printing Username");
         }
         else if (user.ID == 0)
         {
             throw new Exception("Invalid User Printing Username");
         }
         else
         {
             return(CardAccountRequestDL.RecordsToBePrinted(Convert.ToInt64(user.UserBranch)));
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.WriteError(ex);
         throw ex;
     }
 }
        public CardAccountRequestModel[] GetListofData(string loggedInUsername)
        {
            try
            {
                var user = UserPL.RetrieveUserByUsername(loggedInUsername);
                if (user == null)
                {
                    throw new Exception("Invalid User Printing Username");
                }
                else if (user.ID == 0)
                {
                    throw new Exception("Invalid User Printing Username");
                }
                else
                {
                    var result = new List <CardAccountRequestModel>();

                    var cars = CardAccountRequestDL.GetListofData(Convert.ToInt64(user.UserBranch));
                    if (cars.Any())
                    {
                        cars.ForEach(car =>
                        {
                            var c = new CardAccountRequestModel
                            {
                                ID                  = car.ID,
                                LicenseID           = car.LicenseID,
                                Lastname            = car.Lastname,
                                FirstName           = car.FirstName,
                                MiddleName          = car.MiddleName,
                                NameOnCard          = car.NameOnCard,
                                DateOfBirth         = car.DateOfBirth,
                                MaritalStatus       = car.MaritalStatus,
                                Sex                 = car.Sex,
                                Religion            = car.Religion,
                                MothersMaidenName   = car.MothersMaidenName,
                                Nationality         = car.Nationality,
                                UtilityBill         = car.UtilityBill,
                                IDNumber            = car.IDNumber,
                                LocalGovernmentArea = car.LocalGovernmentArea,
                                BloodGroup          = car.BloodGroup,
                                LicenseType         = car.LicenseType,
                                IssueDate           = car.IssueDate,
                                ValidTillDate       = car.ValidTillDate,
                                FileNumber          = car.FileNumber,
                                EmailAddress        = car.EmailAddress,
                                PhoneNumber         = car.PhoneNumber,
                                Address             = car.Address,
                                PrintStatus         = Convert.ToInt32(car.PrintStatus),
                                UserPrinting        = car.UserPrinting
                            };

                            result.Add(c);
                        });
                    }

                    return(result.ToArray());
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteError(ex);
                throw ex;
            }
        }
        public Response SaveData(EnrolmentModel enrolmentData)
        {
            try
            {
                if (!string.IsNullOrEmpty(enrolmentData.UserPrinting))
                {
                    var user = UserPL.RetrieveUserByUsername(enrolmentData.UserPrinting);
                    if (user == null)
                    {
                        throw new Exception("Invalid User Printing Username");
                    }
                    else if (user.ID == 0)
                    {
                        throw new Exception("Invalid User Printing Username");
                    }
                    else
                    {
                        var car = new CardAccountRequest
                        {
                            Lastname            = enrolmentData.Lastname,
                            FirstName           = enrolmentData.FirstName,
                            MiddleName          = enrolmentData.MiddleName,
                            NameOnCard          = enrolmentData.NameOnCard,
                            DateOfBirth         = enrolmentData.DateOfBirth,
                            MaritalStatus       = enrolmentData.MaritalStatus,
                            Sex                 = enrolmentData.Sex,
                            Religion            = enrolmentData.Religion,
                            MothersMaidenName   = enrolmentData.MothersMaidenName,
                            Nationality         = enrolmentData.Nationality,
                            UtilityBill         = enrolmentData.UtilityBill,
                            IDNumber            = enrolmentData.IDNumber,
                            LocalGovernmentArea = enrolmentData.LocalGovernmentArea,
                            BloodGroup          = enrolmentData.BloodGroup,
                            LicenseType         = enrolmentData.LicenseType,
                            IssueDate           = enrolmentData.IssueDate,
                            ValidTillDate       = enrolmentData.ValidTillDate,
                            FileNumber          = enrolmentData.FileNumber,
                            EmailAddress        = enrolmentData.EmailAddress,
                            PhoneNumber         = enrolmentData.PhoneNumber,
                            Address             = enrolmentData.Address,
                            Photo               = enrolmentData.Photo,
                            FingerIdLeft        = enrolmentData.FingerIdLeft,
                            FingerPrintLeft     = enrolmentData.FingerPrintLeft,
                            FingerIdRight       = enrolmentData.FingerIdRight,
                            FingerPrintRight    = enrolmentData.FingerPrintRight,
                            PrintStatus         = 1,
                            UserPrinting        = enrolmentData.UserPrinting,
                            DateEnroled         = System.DateTime.Now,
                            LicenseID           = String.Format("{0:dMyyyyHHmmss}", System.DateTime.Now),
                            BranchID            = user.UserBranch
                        };

                        long recordID = 0;
                        bool saved    = CardAccountRequestDL.Save(car, out recordID);
                        if (saved)
                        {
                            return(new Response
                            {
                                Result = "Success",
                                RecordID = recordID,
                            });
                        }
                        else
                        {
                            return(new Response
                            {
                                Result = "Failed",
                                RecordID = 0,
                                ErrMessage = "Operation Failed"
                            });
                        }
                    }
                }
                else
                {
                    return(new Response
                    {
                        Result = "Failed",
                        RecordID = 0,
                        ErrMessage = "User printing username is required."
                    });
                }
            }
            catch (Exception ex)
            {
                return(new Response
                {
                    Result = "Failed",
                    RecordID = 0,
                    ErrMessage = ex.Message
                });
            }
        }