Exemplo n.º 1
0
        public static JqGridResponse Edit(EditMemberManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderMember aMember = new ProviderMember(model.Id);

            if (currentMember.CanEdit(aMember))
            {
                aMember.IsArticleAdmin = model.IsArticleAdmin;
                aMember.IsBanned = model.IsBanned;
                aMember.IsCategoryAdmin = model.IsCategoryAdmin;
                aMember.IsMasterAdmin = model.IsMasterAdmin;
                aMember.IsMemberAdmin = model.IsMemberAdmin;
                aMember.IsSuperAdmin = model.IsSuperAdmin;

                try
                {
                    aMember.Save();
                    aResponse.Success = true;
                }
                catch (Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Exemplo n.º 2
0
        public static JqGridResponse Edit(EditCommentManagementVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderComment aComment = new ProviderComment(model.Id);
            if (currentMember.CanEdit(aComment))
            {
                aComment.IgnoreFlags = model.IgnoreFlags;
                aComment.IsHidden = model.IsHidden;
                try
                {
                    aComment.Save();
                    aResponse.Success = true;
                }
                catch(Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }
Exemplo n.º 3
0
 public static JqGridResponse Delete(EditCommentManagementVM model, ProviderCurrentMember currentMember)
 {
     JqGridResponse aResponse = new JqGridResponse();
     ProviderComment aComment = new ProviderComment(model.Id);
     if (currentMember.CanEdit(aComment))
     {
         if(aComment.Delete())
         {
             aResponse.Success = true;
         }
         else
         {
             aResponse.Success = false;
             aResponse.Message = ErrorStrings.OPERATION_FAILED;
         }
     }
     else
     {
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
     }
     return aResponse;
 }
Exemplo n.º 4
0
        public virtual ActionResult _EditJqGridArticle(AccountEditArticleVM model)
        {
            JqGridResponse aResponse;
            if (ModelState.IsValid)
            {
                try
                {
                    aResponse = ArticleBL.Process(model.GetJqGridEdit, ProviderCurrentMember.Instance);
                }
                catch (Exception caughtException)
                {
                    InsideWordWebLog.Instance.Log.Error(caughtException);
                    aResponse = new JqGridResponse();
                    aResponse.Success = false;
                    aResponse.Message = caughtException.ToString();
                }
            }
            else
            {
                aResponse = new JqGridResponse();
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.INVALID_INPUT;
            }

            return Json(aResponse);
        }
Exemplo n.º 5
0
        public virtual JsonResult _EditJqGridMember(EditMemberManagementVM model)
        {
            JqGridResponse aResponse;
            if (ModelState.IsValid)
            {
                try
                {
                    aResponse = MemberBL.Process(model, ProviderCurrentMember.Instance);
                }
                catch (Exception caughtException)
                {
                    // DO NOT LOG THIS
                    aResponse = new JqGridResponse();
                    aResponse.Success = false;
                    aResponse.Message = caughtException.ToString();
                }
            }
            else
            {
                aResponse = new JqGridResponse();
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.INVALID_INPUT;
            }

            return Json(aResponse);
        }
Exemplo n.º 6
0
 public static JqGridResponse Process(EditCommentManagementVM model, ProviderCurrentMember currentMember)
 {
     JqGridResponse aResponse;
     if (model.Oper.CompareTo("edit") == 0)
     {
         aResponse = Edit(model, currentMember);
     }
     else if (model.Oper.CompareTo("del") == 0)
     {
         aResponse = Delete(model, currentMember);
     }
     else
     {
         aResponse = new JqGridResponse();
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_UNKNOWN(model.Oper);
     }
     return aResponse;
 }
Exemplo n.º 7
0
        public ActionResult GetGrid(JqGridRequest request, string key, string value, string viewModel, string field, long?id_master)
        {
            string fieldMain = String.Empty;
            long   ID_master;
            bool   result = Int64.TryParse(id_master.ToString(), out ID_master);


            if (String.IsNullOrEmpty(field))
            {
                fieldMain = "ID_ObveznicaJavniDug";
            }

            else
            {
                fieldMain = field;
            }

            viewModel = gridModelNamespace + viewModel;

            string filterExpression = String.Empty;

            if (request.Searching)
            {
                if (request.SearchingFilter != null)
                {
                    filterExpression = GetFilter(request.SearchingFilter.SearchingName, request.SearchingFilter.SearchingOperator, request.SearchingFilter.SearchingValue);
                }
                else if (request.SearchingFilters != null)
                {
                    StringBuilder filterExpressionBuilder  = new StringBuilder();
                    string        groupingOperatorToString = request.SearchingFilters.GroupingOperator.ToString();
                    foreach (JqGridRequestSearchingFilter searchingFilter in request.SearchingFilters.Filters)
                    {
                        filterExpressionBuilder.Append(GetFilter(searchingFilter.SearchingName, searchingFilter.SearchingOperator, searchingFilter.SearchingValue));
                        filterExpressionBuilder.Append(String.Format(" {0} ", groupingOperatorToString));
                    }
                    if (filterExpressionBuilder.Length > 0)
                    {
                        filterExpressionBuilder.Remove(filterExpressionBuilder.Length - groupingOperatorToString.Length - 2, groupingOperatorToString.Length + 2);
                    }
                    filterExpression = filterExpressionBuilder.ToString();
                }
            }
            string sortingName       = request.SortingName;
            long   totalRecordsCount = GetCount(filterExpression, key, value);


            JqGridResponse response = new JqGridResponse()
            {
                TotalPagesCount   = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount),
                PageIndex         = request.PageIndex,
                TotalRecordsCount = totalRecordsCount,
            };


            response.Records.AddRange
            (
                from item in GetGridData(filterExpression, key, value, String.Format("{0} {1}", sortingName, request.SortingOrder), request.PageIndex * request.RecordsCount, (request.PagesCount.HasValue ? request.PagesCount.Value : 1) * request.RecordsCount)
                select new JqGridRecord(Convert.ToString(item.GetType().GetProperty(fieldMain).GetValue(item, null)), Activator.CreateInstance(Type.GetType(viewModel), new[] { item }))
            );


            return(new JqGridJsonResult()
            {
                Data = response
            });
        }
Exemplo n.º 8
0
 public static JqGridResponse Delete(JqGridEditArticleVM model, ProviderCurrentMember currrentMember)
 {
     JqGridResponse aResponse = new JqGridResponse();
     ProviderArticle anArticle = new ProviderArticle(model.Id);
     if (currrentMember.CanEdit(anArticle))
     {
         if (anArticle.Delete())
         {
             aResponse.Success = true;
         }
         else
         {
             aResponse.Success = false;
             aResponse.Message = ErrorStrings.OPERATION_FAILED;
         }
     }
     else
     {
         aResponse.Success = false;
         aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
     }
     return aResponse;
 }
Exemplo n.º 9
0
        public static JqGridResponse Edit(JqGridEditArticleVM model, ProviderCurrentMember currentMember)
        {
            JqGridResponse aResponse = new JqGridResponse();
            ProviderArticle anArticle = new ProviderArticle(model.Id);
            if (currentMember.CanEdit(anArticle))
            {
                anArticle.IgnoreFlags = model.IgnoreFlags;
                anArticle.IsHidden = model.IsHidden;
                anArticle.IsPublished = model.IsPublished;
                try
                {
                    anArticle.Save();
                    aResponse.Success = true;
                }
                catch (Exception caughtException)
                {
                    aResponse.Success = false;
                    aResponse.Message = ErrorStrings.OPERATION_FAILED;
                }
            }
            else
            {
                aResponse.Success = false;
                aResponse.Message = ErrorStrings.OPERATION_NO_RIGHTS;
            }

            return aResponse;
        }