//UpdateCategory
        public JsonExecuteResult UpdateCategory(long cat_id, string title, string description, bool isactive, int priority)
        {
            try
              {
            bool newCategory = false;
            Category cat = (cat_id == -1) ? null : GetCategory(cat_id);
            if (cat == null)
            {
              cat = new Category();
              newCategory = true;
            }
            Category tmp;
            if ((tmp=dataContext.Categories.SingleOrDefault(C => C.Title.ToLower() == title.ToLower() && C.ID != cat.ID)) != null)
              return new JsonExecuteResult(JsonExecuteResultTypes.ERROR, "You can't add this category, because the category with the same name is already exist (Category#" + tmp.ID.ToString() + ")");
            cat.Title = title;
            cat.Description = description;
            cat.IsActive = isactive;
            cat.Priority = priority;
            cat.DateEntered = DateTime.Now;
            cat.Owner_ID = AppHelper.CurrentUser.ID;
            cat.LastUpdate = DateTime.Now;
            if (newCategory) dataContext.Categories.InsertOnSubmit(cat);

            if (!newCategory && !cat.IsActive)
            {
              List<CategoriesMap> Cat = dataContext.CategoriesMaps.Where(C => C.Category_ID == cat.ID).ToList();
              foreach (CategoriesMap cm in Cat)
            cm.IsActive = cat.IsActive;

              if (dataContext.Auctions.Where(A => A.EventCategory.Category_ID == cat.ID).Count() > 0)
              {
            List<string> str = new List<string>();
            var res = from A in dataContext.Auctions
                      where A.EventCategory.Category_ID == cat.ID && A.Status != (byte)Consts.AuctionStatus.Locked
                      orderby A.Status
                      group A.Status by A.Status;
            foreach (var r in res)
            {
              if (r.Count() > 0)
                str.Add(String.Format("{0} {1} auction{2}", r.Count(), ((Consts.AuctionStatus)r.Key).ToString().ToLower(), (r.Count() > 1) ? "s" : String.Empty));
            }
            if (str.Count() > 0)
              return new JsonExecuteResult(JsonExecuteResultTypes.ERROR, "You can't set this category as unactive, because there are auctions in the database which are using this category.", str.ToArray());
              }
            }
            GeneralRepository.SubmitChanges(dataContext);
              }
              catch (Exception ex)
              {
            return new JsonExecuteResult(JsonExecuteResultTypes.ERROR, ex.Message);
              }
              return new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS);
        }
 //UpdateCategory
 public JsonExecuteResult UpdateCategory(long cat_id, string title, string description, bool isactive)
 {
     try
       {
     //bool newCategory = false;
     Category cat = (cat_id == -1) ? null : GetCategory(cat_id);
     if (cat == null)
     {
       cat = new Category();
       dataContext.Categories.InsertOnSubmit(cat);
       //newCategory = true;
     }
     cat.Title = title;
     cat.Description = description;
     cat.IsActive = isactive;
     cat.LastUpdate = DateTime.Now;
     cat.DateEntered = DateTime.Now;
     cat.Priority = 1;
     //if (!newCategory && !cat.IsActive)
     //{
     //  List<CategoriesMap> evCat = dataContext.CategoriesMaps.Where(C => C.Category_ID == cat.ID).ToList();
     //  List<CategoriesMap> lst = new List<CategoriesMap>();
     //  foreach (CategoriesMap ec in evCat)
     //    AddSubCategoriesMap(lst, ec);
     //  foreach (CategoriesMap ec in lst)
     //    ec.IsDefault = false;
     //  List<EventCategory> ev = (from E in dataContext.EventCategories
     //                            where lst.Contains(E.CategoriesMap)
     //                            select E).ToList();
     //  foreach (EventCategory e in ev)
     //    e.IsActive = cat.IsActive;
     //  ev = null;
     //  lst = null;
     //  evCat = null;
     //  if (dataContext.Auctions.Where(A => A.EventCategory.CategoriesMap.Category_ID == cat.ID).Count() > 0)
     //  {
     //    List<string> str = new List<string>();
     //    var res = from A in dataContext.Auctions
     //              where A.EventCategory.CategoriesMap.Category_ID == cat.ID && A.Status_ID != (byte)Consts.AuctionStatus.Locked
     //              orderby A.Status_ID
     //              group A.Status_ID by A.Status_ID;
     //    foreach (var r in res)
     //    {
     //      if (r.Count() > 0)
     //        str.Add(String.Format("{0} {1} auction{2}", r.Count(), ((Consts.AuctionStatus)r.Key).ToString().ToLower(), (r.Count() > 1) ? "s" : String.Empty));
     //    }
     //    if (str.Count() > 0)
     //      return new JsonExecuteResult(JsonExecuteResultTypes.ERROR, "You can't set this category as unactive, because there are auctions in the database which are using this category.", str.ToArray());
     //  }
     //}
     GeneralRepository.SubmitChanges(dataContext);
       }
       catch (Exception ex)
       {
     return new JsonExecuteResult(JsonExecuteResultTypes.ERROR, ex.Message);
       }
       return new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS);
 }