public HttpResponseMessage RegisterUser([FromBody] UserDTO user)
        {
            try
            {
                OperationResult operationResult = new OperationResult();
                //Business Logic
                var         userInfo   = (UserDTO)operationResult.Data;
                UserManager jobManager = new UserManager();
                operationResult = new UserManager().RegisterUser(user.Practicetype, user.Project_Code, user.Project_Name, user.Category,
                                                                 user.Sub_Category, user.Category_ID, user.Sub_Category_ID, user.Header, user.Abstract, user.Detailed_Content,
                                                                 user.Meta_Tags, user.Tangible_Intangible_Benefits, user.KeyTeam_Involved, user.Comments, user.Status,
                                                                 user.Pending_With, user.AttachmentPath);

                return(this.Request.CreateResponse(HttpStatusCode.OK, operationResult, "text/json"));
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.Request.CreateResponse(HttpStatusCode.OK, exception.Result, "text/json"));
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.GetExceptionAsJsonResponse(exception));
            }
        }
Esempio n. 2
0
 public OperationResult UpdateAPNSToken(string userEmail, string apnsToken)
 {
     try
     {
         userEmail.GuardNullEmpty("User Email");
         apnsToken.GuardNullEmpty("APNS Token");
         using (UnitOfWork uow = new UnitOfWork())
         {
             var  userDB    = uow.GetDbInterface <UserDB>();
             bool isSuccess = userDB.UpdateAPNSToken(userEmail, apnsToken);
             return(new OperationResult()
             {
                 Success = isSuccess,
                 Message = isSuccess ? "Updated successfully" : "Unable to update apns token",
                 MCode = isSuccess ? MessageCode.OperationSuccessful : MessageCode.OperationFailed
             });
         }
     }
     catch (SIPException exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         return(exception.Result);
     }
     catch (Exception exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
Esempio n. 3
0
        public bool RegisterUser(string Practicetype, string Project_Code, string Project_Name, string Category,
                                 string Sub_Category, string Category_ID, string Sub_Category_ID, string Header, string Abstract, string Detailed_Content,
                                 string Meta_Tags, string Tangible_Intangible_Benefits, string KeyTeam_Involved, string Comments, string Status,
                                 string Pending_With, string AttachmentPath)
        {
            try
            {
                Best_Practice_dt userInfoDB = new Best_Practice_dt();
                userInfoDB.Practicetype                 = Practicetype;
                userInfoDB.Project_Code                 = Project_Code;
                userInfoDB.Project_Name                 = Project_Name;
                userInfoDB.Category                     = Category;
                userInfoDB.Sub_Category                 = Sub_Category;
                userInfoDB.Category_ID                  = Category_ID;
                userInfoDB.Sub_Category_ID              = Sub_Category_ID;
                userInfoDB.Header                       = Header;
                userInfoDB.Abstract                     = Abstract;
                userInfoDB.Detailed_Content             = Detailed_Content;
                userInfoDB.Meta_Tags                    = Meta_Tags;
                userInfoDB.Tangible_Intangible_Benefits = Tangible_Intangible_Benefits;
                userInfoDB.KeyTeam_Involved             = KeyTeam_Involved;
                userInfoDB.Status                       = Status;
                userInfoDB.Pending_With                 = Pending_With;
                userInfoDB.AttachmentPath               = AttachmentPath;

                this.dbContext.Entry(userInfoDB).State = System.Data.Entity.EntityState.Added;
                return(this.dbContext.SaveChanges() > 0);
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
 public int DeleteEnumeration(TemplateDto template)
 {
     try {
         return(objDBFrameworkBL.DeleteEnumeration(template));
     } catch (Exception ex) {
         LogUtilities.LogException(ex);
         return(0);
     }
 }
Esempio n. 5
0
        public OperationResult VerifyCredentials(string userName, string password)
        {
            try
            {
                userName.GuardNullEmpty("User Name");
                password.GuardNullEmpty("Password");
                using (UnitOfWork uow = new UnitOfWork())
                {
                    var v          = uow.GetDbInterface <UserDB>();
                    var userDetail = v.GetUser(userName);

                    ////TODO: Need to uncomment after Mobile side implementaion done.
                    ////string decryptedpassword = SIPAuthentication.Decrypt(password);

                    ////if (userDetail != null && decryptedpassword.Equals(password))
                    if (userDetail != null && userDetail.Password.Equals(password))
                    {
                        UserDTO user = new UserDTO
                        {
                            Id              = userDetail.Id,
                            EmailId         = userDetail.EmailId,
                            Password        = userDetail.Password,
                            APNSToken       = userDetail.APNSToken,
                            Name            = userDetail.Name,
                            PhoneNumber     = userDetail.PhoneNumber,
                            City            = userDetail.City,
                            CreatedDateTime = userDetail.CreatedDateTime.GetValueOrDefault()
                        };

                        return(new OperationResult
                        {
                            Success = true,
                            Data = user,
                            MCode = MessageCode.OperationSuccessful,
                            Message = "Valid User logged in"
                        });
                    }
                }

                return(new OperationResult
                {
                    Success = false,
                    MCode = MessageCode.InvalidCredentials,
                    Message = "Please provide valid username/password."
                });
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(exception.Result);
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Esempio n. 6
0
 public UserInformation GetUser(string userName)
 {
     try
     {
         UserInformation userDetail = this.dbContext.UserInformations.Where(a => a.EmailId.Equals(userName)).FirstOrDefault();
         return(userDetail);
     }
     catch (Exception exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
Esempio n. 7
0
 public Best_Practice_dt GetUser(string userName)
 {
     try
     {
         //Best_Practice_dt userDetail = this.dbContext.Best_Practice_dt.Where(a => a.EmailId.Equals(userName)).FirstOrDefault();
         return(null);
     }
     catch (Exception exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
Esempio n. 8
0
        public OperationResult RegisterUser(string EmailId, string Password, string APNSToken, string Name, string PhoneNumber, string City)
        {
            try
            {
                bool isSuccess;
                EmailId.GuardNullEmpty("EmailId");
                Password.GuardNullEmpty("Password");
                APNSToken.GuardNullEmpty("APNSToken");
                Name.GuardNullEmpty("Name");
                PhoneNumber.GuardNullEmpty("PhoneNumber");
                City.GuardNullEmpty("City");

                UserInformation user = default(UserInformation);

                using (UnitOfWork uow = new UnitOfWork())
                {
                    var userDB = uow.GetDbInterface <UserDB>();
                    isSuccess = userDB.RegisterUser(EmailId, Password, APNSToken, Name, PhoneNumber, City);
                }

                SendPushNotification pushNotify = new SendPushNotification();
                pushNotify.Send(APNSToken);

                //SendPushNotification();

                //if (isSuccess)
                //{
                //    NotificationHandler.NotificationHandler handler = new NotificationHandler.NotificationHandler();
                //    handler.Send("", user.APNSToken, "Registration success.", ICConstant.MsgForUserRegistration, "");
                //}

                return(new OperationResult()
                {
                    Success = true,
                    Message = "User registered successfully",
                    MCode = MessageCode.OperationSuccessful,
                    Data = isSuccess
                });
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(exception.Result);
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Esempio n. 9
0
 public bool UpdateAPNSToken(string userEmail, string apnsToken)
 {
     try
     {
         var user = this.dbContext.UserInformations.Where(a => a.EmailId == userEmail).FirstOrDefault();
         user.APNSToken = apnsToken;
         this.dbContext.Entry(user).State = System.Data.Entity.EntityState.Modified;
         return(this.dbContext.SaveChanges() > 0);
     }
     catch (Exception exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
Esempio n. 10
0
        public HttpResponseMessage Login([FromBody] UserDTO user)
        {
            try
            {
                OperationResult operationResult = new OperationResult();
                AccountHandler  accountHandler  = new AccountHandler();
                user.GuardNull("User Details");
                var result = accountHandler.VerifyCredentials(user.EmailId, user.Password);
                if (result.Success)
                {
                    var userDetails = (UserDTO)result.Data;
                    if (userDetails.UserType != UserType.Administrator)
                    {
                        operationResult.Success = result.Success;
                        operationResult.MCode   = result.MCode;
                        operationResult.Message = result.Message;
                        //var token = CipherHandler.GenerateHashWithSalt(user.UserName + user.Password);
                        //JobManager jobManager = new JobManager();
                        ////bool isAnyEmergencyAvailable = userDetails.UserType == UserType.Mechanic ? jobManager.IsAnyEmergency(userDetails.UserID) : false;
                        operationResult.Data = new { UserInfo = result.Data };
                    }
                    else
                    {
                        operationResult.Data    = null;
                        operationResult.MCode   = MessageCode.InvalidCredentials;
                        operationResult.Message = "Please provide valid username/password.";
                        operationResult.Success = false;
                    }
                }
                else
                {
                    operationResult = result;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, operationResult, "text/json"));
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.Request.CreateResponse(HttpStatusCode.OK, exception.Result, "text/json"));
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.GetExceptionAsJsonResponse(exception));
            }
        }
Esempio n. 11
0
        public HttpResponseMessage Login([FromBody] UserDTO user)
        {
            try
            {
                OperationResult operationResult = new OperationResult();


                return(this.Request.CreateResponse(HttpStatusCode.OK, operationResult, "text/json"));
            }

            catch (SchoolERPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.Request.CreateResponse(HttpStatusCode.OK, exception.Result, "text/json"));
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.GetExceptionAsJsonResponse(exception));
            }
        }
Esempio n. 12
0
 public bool RegisterUser(string EmailId, string Password, string APNSToken, string Name, string PhoneNumber, string City)
 {
     try
     {
         UserInformation userInfoDB = new UserInformation();
         userInfoDB.EmailId                     = EmailId;
         userInfoDB.Password                    = Password;
         userInfoDB.APNSToken                   = APNSToken;
         userInfoDB.Name                        = Name;
         userInfoDB.PhoneNumber                 = PhoneNumber;
         userInfoDB.City                        = City;
         userInfoDB.CreatedDateTime             = DateTime.UtcNow;
         this.dbContext.Entry(userInfoDB).State = System.Data.Entity.EntityState.Added;
         return(this.dbContext.SaveChanges() > 0);
     }
     catch (Exception exception)
     {
         LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
Esempio n. 13
0
        public HttpResponseMessage UpdateAPNSToken([FromBody] UserDTO user)
        {
            try
            {
                user.GuardNull("user");
                OperationResult operationResult = new OperationResult();
                operationResult = new UserManager().UpdateAPNSToken(user.EmailId, user.APNSToken);


                return(this.Request.CreateResponse(HttpStatusCode.OK, operationResult, "text/json"));
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.Request.CreateResponse(HttpStatusCode.OK, exception.Result, "text/json"));
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.GetExceptionAsJsonResponse(exception));
            }
        }
Esempio n. 14
0
        public OperationResult RegisterUser(string Practicetype, string Project_Code, string Project_Name, string Category,
                                            string Sub_Category, string Category_ID, string Sub_Category_ID, string Header, string Abstract, string Detailed_Content,
                                            string Meta_Tags, string Tangible_Intangible_Benefits, string KeyTeam_Involved, string Comments, string Status,
                                            string Pending_With, string AttachmentPath)
        {
            try
            {
                bool isSuccess;

                Best_Practice_dt user = default(Best_Practice_dt);

                using (UnitOfWork uow = new UnitOfWork())
                {
                    var userDB = uow.GetDbInterface <UserDB>();
                    isSuccess = userDB.RegisterUser(Practicetype, Project_Code, Project_Name, Category,
                                                    Sub_Category, Category_ID, Sub_Category_ID, Header, Abstract, Detailed_Content,
                                                    Meta_Tags, Tangible_Intangible_Benefits, KeyTeam_Involved, Comments, Status,
                                                    Pending_With, AttachmentPath);
                }

                return(new OperationResult()
                {
                    Success = true,
                    Message = "User registered successfully",
                    MCode = MessageCode.OperationSuccessful,
                    Data = false
                });
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(exception.Result);
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Esempio n. 15
0
        public HttpResponseMessage RegisterUser([FromBody] UserDTO user)
        {
            try
            {
                OperationResult operationResult = new OperationResult();
                //Business Logic
                var         userInfo   = (UserDTO)operationResult.Data;
                UserManager jobManager = new UserManager();
                operationResult = new UserManager().RegisterUser(user.EmailId, user.Password, user.APNSToken, user.Name, user.PhoneNumber, user.City);

                return(this.Request.CreateResponse(HttpStatusCode.OK, operationResult, "text/json"));
            }
            catch (SIPException exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.Request.CreateResponse(HttpStatusCode.OK, exception.Result, "text/json"));
            }
            catch (Exception exception)
            {
                LogUtilities.LogException(exception, LogPriorityID.High, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
                return(this.GetExceptionAsJsonResponse(exception));
            }
        }