Example #1
0
        public ResponseResult IdeaExist(Project proj)
        {

            String msg;
            try
            {
                var result = DataService.CheckIdeaExist(proj.UserId);
                if (result > 0)
                {
                    msg = "you have already initiated a idea!";

                    return ResponseResult.GetSuccessObject(new
                       {
                           ProjectId = result,
                       },
                       msg);
                }
                else
                {
                    return ResponseResult.GetErrorObject();
                }

            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return ResponseResult.GetErrorObject();
            } 
        }
Example #2
0
 public ResponseResult Download(String id)
 {
     try
     {
         var clientKey = User.Identity.Name;
         var file      = DocsAPI.Models.DocsBAL.GetFileByID(id, clientKey);
         if (file != null)
         {
             return(ResponseResult.GetSuccessObject(new {
                 FileActualName = file.ActualFileName,
                 FileSize = file.ConentLengthInBytes,
                 FileType = file.ContentType,
                 Extension = file.Extension,
                 UniqueID = file.UniqueName
             }));
         }
         else
         {
             return(ResponseResult.GetErrorObject("Not Found"));
         }
     }
     catch (Exception ex)
     {
         Utility.HandleException(ex);
         return(ResponseResult.GetErrorObject("Not Found"));
     }
 }
Example #3
0
 public ResponseResult SaveOrder(Order order)
 {
     try
     {
         var sendEmail = Convert.ToBoolean(ConfigurationManager.AppSettings["SendEmail"]);
         if (!ModelState.IsValid)
         {
             return(ResponseResult.GetErrorObject());
         }
         if (new DataService().SaveOrder(order))
         {
             if (sendEmail && (order.Customer.Email != null || !order.Customer.Email.Equals("")))
             {
                 if (new DataService().SendEmail(order.Customer.Email))
                 {
                     return(ResponseResult.GetSuccessObject("Order Has been placed saved & email is sent"));
                 }
             }
         }
         return(ResponseResult.GetSuccessObject(null, "Order Has been placed saved"));
     }catch (Exception exp)
     {
         return(ResponseResult.GetErrorObject());
     }
 }
Example #4
0
        public ResponseResult updateUserProfile(EditUser u)
        {
            String msg;

            try
            {
                int isUpdated = DataService.updateUserProfile(u);
                if (isUpdated == 1)
                {
                    msg = "User Updated Successfully";
                    return(ResponseResult.GetSuccessObject(new
                    {
                        IsUpdated = isUpdated
                    }, msg));
                }
                else
                {
                    msg = "User didn't updated successfully";
                    return(ResponseResult.GetErrorObject(msg));
                }
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject("User didn't updated successfully"));
            }
        }
Example #5
0
        //public Object SignOut(Boolean pManualEclockLogout)
        //{
        //    try
        //    {
        //        SessionManager.CurrentUser = null;
        //        SessionManager.AbandonSession();
        //        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        //        HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(-1));
        //        HttpContext.Current.Response.Cache.SetNoStore();

        //        if (HttpContext.Current.Request.Cookies["breadcrumbs"] != null)
        //        {
        //            HttpCookie myCookie = new HttpCookie("breadcrumbs");
        //            myCookie.Expires = DateTime.UtcNow.AddDays(-1d);
        //            HttpContext.Current.Response.Cookies.Add(myCookie);
        //        }

        //        return ResponseResult.GetSuccessObject();

        //        //var result = new
        //        //{
        //        //    success = true,
        //        //    error = ""
        //        //};

        //        //return (result);

        //    }
        //    catch (Exception ex)
        //    {
        //        CustomUtility.HandleException(ex);
        //        return ResponseResult.GetErrorObject("Email not correct");
        //    }
        //}

        public ResponseResult ResetPassword(PasswordEntity pass)
        {
            if (PUCIT.AIMRL.SFP.UI.Common.SessionManager.LogsInAsOtherUser == true)
            {
                return(ResponseResult.GetErrorObject("You Are Not Allowed"));
            }
            try
            {
                var password = pass.NewPassword;
                if (GlobalDataManager.IgnoreHashing == false)
                {
                    password = PasswordSaltedHashingUtility.HashPassword(pass.NewPassword);
                }

                var flag = DataService.UpdatePassword(pass.Token, "", password, 0, DateTime.UtcNow, false);

                if (flag)
                {
                    return(ResponseResult.GetSuccessObject(null, "Password is reset"));
                }
                else
                {
                    return(ResponseResult.GetErrorObject("Reset is failed"));
                }
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
Example #6
0
 public ResponseResult getUsers()
 {
     try
     {
         var List = DataService.GetAllUsers();
         return(ResponseResult.GetSuccessObject(new
         {
             UserList = List
         }));
         //return (new
         //{
         //    data = new
         //    {
         //        UserList = List
         //    },
         //    success = true,
         //    error = ""
         //});
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #7
0
 public ResponseResult SearchUsers(UserSearchParam pSearchParam)
 {
     try
     {
         var result = DataService.SearchUsers(pSearchParam);
         return(ResponseResult.GetSuccessObject(new
         {
             Count = result.ResultCount,
             UserList = result.Result
         }));
         //return (new
         //{
         //    data = new
         //    {
         //        Count = result.ResultCount,
         //        UserList = result.Result
         //    },
         //    success = true,
         //    error = ""
         //});
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #8
0
 public ResponseResult SaveUsers(User u)
 {
     try
     {
         String msg;
         u.Password = PasswordSaltedHashingUtility.HashPassword("123");
         var result = DataService.SaveUsers(u, DateTime.UtcNow, SessionManager.CurrentUser.UserId);
         if (result > 0)
         {
             if (u.UserId > 0)
             {
                 msg = "User Updated Successfully";
             }
             else
             {
                 msg = "User Added Successfully";
             }
             return(ResponseResult.GetSuccessObject(new
             {
                 UserId = result,
             }, msg));
         }
         else
         {
             return(ResponseResult.GetErrorObject());
         }
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #9
0
        public ResponseResult SaveUserRoleMapping(int pUserID, List <int> pRoles)
        {
            try
            {
                var List = DataService.SaveUserRoleMapping(pUserID, pRoles);
                return(ResponseResult.GetSuccessObject(new
                {
                    Roles = List
                }, "Mappings are saved"));

                //return (new
                //{
                //    data = new
                //    {
                //        Roles = List
                //    },
                //    success = true,
                //    error = "Mappings are saved"
                //});
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
Example #10
0
 public ResponseResult GetRolesByUserID(int pUserID)
 {
     try
     {
         var List = DataService.GetRolesByUserID(pUserID);
         return(ResponseResult.GetSuccessObject(new
         {
             Roles = List
         }));
         //return (new
         //{
         //    data = new
         //    {
         //        Roles = List
         //    },
         //    success = true,
         //    error = ""
         //});
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #11
0
        public ResponseResult GetActivePermissions()
        {
            try
            {
                var List = DataService.GetAllPermissions().Where(p => p.IsActive == true).ToList();

                return(ResponseResult.GetSuccessObject(new
                {
                    PermissionList = List
                }));

                //return (new
                //{
                //    data = new
                //    {
                //        PermissionList = List
                //    },
                //    success = true,
                //    error = ""
                //});
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
        public ResponseResult SearchLoginHistory(LoginHistorySearchParam pSearchParam)
        {
            try
            {
                if (pSearchParam.SDate <= DateTime.MinValue)
                {
                    pSearchParam.SDate = new DateTime(1900, 1, 1);
                }

                if (pSearchParam.EDate <= DateTime.MinValue)
                {
                    pSearchParam.EDate = DateTime.MaxValue;
                }

                var result = DataService.SearchLoginHistory(pSearchParam);

                return(ResponseResult.GetSuccessObject(new
                {
                    Count = result.ResultCount,
                    LoginHistoryList = result.Result
                }));
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
Example #13
0
        public static ResponseResult GetAllOrders()
        {
            try
            {
                var query = "Select ord.OrderId,ord.OrderNum, ord.OrderBy,u.Name, ord.CreatedOn,ord.IsPaid, ord.TotalAmount,ord.IsActive,ord.OrderStatus from dbo.Orders ord,dbo.Users u Where ord.OrderBy=u.UserId AND ord.IsActive = 1";

                using (DBHelper helper = new DBHelper())
                {
                    var             reader = helper.ExecuteReader(query);
                    List <OrderDTO> list   = new List <OrderDTO>();

                    while (reader.Read())
                    {
                        var dto = FillDTO(reader);
                        if (dto != null)
                        {
                            list.Add(dto);
                        }
                    }

                    return(ResponseResult.GetSuccessObject(list));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject("Some Error has occured! " + exp));
            }
        }
Example #14
0
        public ResponseResult getUserInfo(int UserId)
        {
            try
            {
                User StudentObject = DataService.getUserInfo(UserId);
                //Section UserSection = DataService.getUserSection(StudentObject.UserId);

                return(ResponseResult.GetSuccessObject(new
                {
                    StudentInfo = StudentObject
                }));

                //return (new
                //{
                //    data = new
                //    {
                //        StudentInfo = StudentObject
                //    },
                //    success = true,
                //    error = ""
                //});
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
        public static ResponseResult GetProductById(int pid)
        {
            var sqlQuery = "";

            try
            {
                using (DBHelper helper = new DBHelper())
                {
                    sqlQuery = String.Format(@"Select * from dbo.Products Where ProductId='{0}'", pid);

                    SqlCommand cmd = new SqlCommand(sqlQuery);

                    var reader = helper.ExecuteReader(sqlQuery);

                    ProductDTO dto = null;

                    if (reader.Read())
                    {
                        dto = FillDTO(reader);
                    }

                    return(ResponseResult.GetSuccessObject(dto));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject());
            }
        }
        public static ResponseResult GetProductsByOrderId(int OrderId)
        {
            var sqlQuery = "";

            try
            {
                using (DBHelper helper = new DBHelper())
                {
                    sqlQuery = String.Format(@"select p.ProductId,p.Name, p.Price, p.PictureName, p.CreatedOn,p.CreatedBy, p.ModifiedOn, p.ModifiedBy, p.IsActive from dbo.Products p,dbo.Orders ord, dbo.ProductOrderMapping map
WHERE map.ProductId=p.ProductId AND ord.OrderId=map.OrderId AND ord.OrderId={0}", OrderId);

                    SqlCommand cmd = new SqlCommand(sqlQuery);

                    var reader = helper.ExecuteReader(sqlQuery);

                    List <ProductDTO> list = new List <ProductDTO>();

                    while (reader.Read())
                    {
                        var dto = FillDTO(reader);
                        if (dto != null)
                        {
                            list.Add(dto);
                        }
                    }

                    return(ResponseResult.GetSuccessObject(list));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject());
            }
        }
Example #17
0
 public ResponseResult GetAllModels(int id)
 {
     try
     {
         using (DBEntitiesModel db = new DBEntitiesModel())
         {
             var data = db.Devices.Where(x => x.ParentID == id && x.IsActive == true).
                        Select(y => new DeviceDTO
             {
                 DeviceID    = y.DeviceID,
                 DeviceName  = y.DeviceName,
                 Description = y.Description,
                 ImageName   = y.ImageName,
                 IsActive    = y.IsActive,
                 ParentID    = y.ParentID,
                 CreatedBy   = y.CreatedBy,
                 CreatedOn   = y.CreatedOn
             }
                               ).ToList();
             return(ResponseResult.GetSuccessObject(data));
         }
     }
     catch (Exception exp) {
         return(ResponseResult.GetErrorObject());
     }
 }
        public static ResponseResult GetAllProducts()
        {
            var query = "Select ProductId,Name, Price, PictureName, CreatedOn,CreatedBy, ModifiedOn, ModifiedBy, IsActive from dbo.Products Where IsActive = 1";

            try
            {
                using (DBHelper helper = new DBHelper())
                {
                    var reader             = helper.ExecuteReader(query);
                    List <ProductDTO> list = new List <ProductDTO>();

                    while (reader.Read())
                    {
                        var dto = FillDTO(reader);
                        if (dto != null)
                        {
                            list.Add(dto);
                        }
                    }

                    return(ResponseResult.GetSuccessObject(list));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject("Some Error has occured! " + exp));
            }
        }
Example #19
0
        public ResponseResult EnableDisableRole(Roles pRoleObj)
        {
            String msg = " ";

            try
            {
                bool rowdeleted = DataService.EnableDisableRole(pRoleObj.Id, pRoleObj.IsActive, DateTime.UtcNow, SessionManager.CurrentUser.UserId);

                if (rowdeleted == true)
                {
                    var param = (pRoleObj.IsActive == false ? "disabled" : "enabled");
                    msg = String.Format("Role is {0} successfully", param);
                }
                else
                {
                    msg = " ";
                }
                return(ResponseResult.GetSuccessObject(new
                {
                    RoleId = pRoleObj.Id
                }, msg));

                //return (new
                //{

                //    success = true,
                //    error = msg
                //});
            }
            catch (Exception ex)
            {
                CustomUtility.HandleException(ex);
                return(ResponseResult.GetErrorObject());
            }
        }
Example #20
0
        public static ResponseResult GetOrderById(int OrderId)
        {
            var sqlQuery = "";

            try
            {
                using (DBHelper helper = new DBHelper())
                {
                    sqlQuery = String.Format(@"Select ord.OrderId,ord.OrderNum, ord.OrderBy,u.Name, ord.CreatedOn,ord.IsPaid, ord.TotalAmount,ord.IsActive,ord.OrderStatus from dbo.Orders ord,dbo.Users u Where ord.OrderBy=u.UserId AND ord.IsActive = 1 AND OrderId='{0}'", OrderId);

                    SqlCommand cmd = new SqlCommand(sqlQuery);

                    var reader = helper.ExecuteReader(sqlQuery);

                    OrderDTO dto = null;

                    if (reader.Read())
                    {
                        dto = FillDTO(reader);
                    }

                    return(ResponseResult.GetSuccessObject(dto));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject("Some error has occured!" + exp));
            }
        }
Example #21
0
        public ResponseResult updateUserProfilePic()
        {
            if (HttpContext.Current.Request.Files.AllKeys.Any())
            {
                // Get the uploaded image from the Files collection
                var httpPostedFile = HttpContext.Current.Request.Files["UploadedImage"];

                //get other form data
                var username = HttpContext.Current.Request.Form["Username"];

                string uniqueName = "";
                if (httpPostedFile != null)
                {
                    // Validate the uploaded image(optional)
                    var ext = System.IO.Path.GetExtension(httpPostedFile.FileName);
                    uniqueName = Guid.NewGuid().ToString() + ext;
                    //You could modify the following code and get the postedfile inputstream, then insert them into database.
                    // Get the complete file path
                    var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/images/gallery"), uniqueName);

                    // Save the uploaded file to "UploadedFiles" folder
                    httpPostedFile.SaveAs(fileSavePath);
                }
                return(Repository.updateUserProfilePic(uniqueName));
            }



            return(ResponseResult.GetErrorObject());
        }
Example #22
0
        // GET: api/Devices/5
        public ResponseResult GetDeviceByID(int id)
        {
            Device device = db.Devices.Find(id);

            if (device == null)
            {
                return(ResponseResult.GetErrorObject());
            }

            return(ResponseResult.GetSuccessObject(device));
        }
Example #23
0
        public ResponseResult SaveDevice(Device device)
        {
            if (!ModelState.IsValid)
            {
                return(ResponseResult.GetErrorObject("Invalid Model State"));
            }

            db.Devices.Add(device);
            db.SaveChanges();
            return(ResponseResult.GetSuccessObject(new { id = device.DeviceID }, ""));
            //return CreatedAtRoute("DefaultApi", new { id = device.DeviceID }, device);
        }
Example #24
0
 public ResponseResult updateUserProfilePic(string fileName)
 {
     try
     {
         return(DataService.updateUserProfilePic(fileName));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
         //return ResponseResult.GetErrorObject("Some error has occured in While showing User Projects Wall.");
     }
 }
 public ResponseResult ValidateUser(Login pLogin)
 {
     try
     {
         Util.CustomUtility.LogData("Going to validate Login:" + pLogin.UserName);
         return(Repository.ValidateUser(pLogin.UserName, pLogin.Password, pLogin.Email, true, true));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #26
0
 public ResponseResult ShareIdea(projectIdea proj)
 {
     try
     {
         Util.CustomUtility.LogData("Going to add new project idea:" + proj.ProjectTitle);
         return(Repository.saveProject(proj));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #27
0
 public ResponseResult IdeaExist(Project proj)
 {
     try
     {
         Util.CustomUtility.LogData("Going to check weather user have already added project idea or not" + proj.UserId);
         return(Repository.IdeaExist(proj));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
 public ResponseResult ValidateUser(Login pLogin)
 {
     try
     {
         UserInfoRepository userInfoRepo = new UserInfoRepository();
         return(userInfoRepo.ValidateUser(pLogin.UserName, "", "", true, true));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #29
0
 public ResponseResult Upload()
 {
     try
     {
         var clientKey = User.Identity.Name;
         var filesList = GetFilesFromRequestAndSave("~/UploadedFiles", clientKey);
         return(ResponseResult.GetSuccessObject(filesList));
     }
     catch (Exception ex)
     {
         Utility.HandleException(ex);
         return(ResponseResult.GetErrorObject());
     }
 }
Example #30
0
 public ResponseResult GetProjectsByUserId(int UserId)
 {
     try
     {
         List <ProjectDTO> listOfUserProjects = DataService.GetProjectsByUserId(UserId);
         return(ResponseResult.GetSuccessObject(new
         {
             ProjectList = listOfUserProjects
         }));
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException(ex);
         return(ResponseResult.GetErrorObject("Some error has occured in While showing User Projects Wall."));
     }
 }