Exemple #1
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());
     }
 }
Exemple #2
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());
            }
        }
Exemple #3
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"));
            }
        }
Exemple #4
0
        //==============================================================//
        public ResponseResult GetProjectDetailsById(int pid)
        {
            using (var db = new PRMDataContext())
            {
                String query = "execute sec.GetProjectDetailsById @1";
                var    cmd   = db.Database.Connection.CreateCommand();
                cmd.CommandText = query;
                cmd.Parameters.Add(new SqlParameter {
                    ParameterName = "@1", Value = pid
                });
                db.Database.Connection.Open();
                var reader = cmd.ExecuteReader();

                // Read User from the first Result set
                var MemberList = ((IObjectContextAdapter)db)
                                 .ObjectContext
                                 .Translate <User>(reader).ToList();
                reader.NextResult();

                //Read Project From 2nd Result set
                var project = ((IObjectContextAdapter)db)
                              .ObjectContext
                              .Translate <ProjectDTO>(reader).FirstOrDefault();
                db.Database.Connection.Close();
                var projDetails = new ProjectDetails();
                projDetails.Project = project;
                projDetails.Members = MemberList;
                return(ResponseResult.GetSuccessObject(projDetails));
                //return projDetails;
            }
        }
Exemple #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());
            }
        }
Exemple #6
0
 public ResponseResult getUserRequests()
 {
     return(ResponseResult.GetSuccessObject(new
     {
         Requests = DataService.getUserRequests()
     }));
 }
Exemple #7
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));
            }
        }
        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());
            }
        }
Exemple #9
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());
     }
 }
Exemple #10
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());
     }
 }
Exemple #11
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());
     }
 }
Exemple #12
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());
            }
        }
Exemple #13
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());
            }
        }
Exemple #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());
            }
        }
Exemple #15
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"));
     }
 }
Exemple #16
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();
            } 
        }
Exemple #17
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());
     }
 }
Exemple #18
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));
            }
        }
        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());
            }
        }
        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 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));
            }
        }
Exemple #22
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());
     }
 }
Exemple #23
0
        //end of function


        public ResponseResult Bid(int ProjectId)
        {
            int UserId = SessionManager.CurrentUser.UserId;
            int result = DataService.SaveBid(UserId, ProjectId);
            return ResponseResult.GetSuccessObject(new
            {
                ResultCode = result,
            });
        }
Exemple #24
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));
        }
Exemple #25
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);
        }
Exemple #26
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());
     }
 }
Exemple #27
0
 public ResponseResult GetProjects()
 {
     try
     {
         List<Project> list = DataService.GetAllProjects ();
         return ResponseResult.GetSuccessObject ( new
         {
             ProjectList = list
         });
     }
     catch (Exception ex)
     {
         CustomUtility.HandleException ( ex );
         return ResponseResult.GetErrorObject ( "Some error has occured in ProjectRepository" );
     }
 }
Exemple #28
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."));
     }
 }
Exemple #29
0
 public ResponseResult GetCommentsByProjectById(int id,int count)
 {
     try
     {
         List<ProjectComments> list = DataService.GetCommentByProjectId(id,count);
         return ResponseResult.GetSuccessObject(new
         {
             Comments = list
         });
     }
     catch(Exception exp)
     {
         CustomUtility.HandleException(exp);
         return ResponseResult.GetErrorObject("Some error has occured in ProjectRepository");
     }
 }
        public static ResponseResult DeleteProduct(int id)
        {
            try
            {
                String sqlQuery = String.Format(@"Update dbo.Products Set IsActive=0 Where ProductId={0}", id);

                using (DBHelper helper = new DBHelper())
                {
                    SqlCommand cmd = new SqlCommand(sqlQuery);
                    return(ResponseResult.GetSuccessObject(helper.ExecuteQuery(sqlQuery)));
                }
            }
            catch (Exception exp)
            {
                return(ResponseResult.GetErrorObject("Some Error has occured " + exp));
            }
        }