Пример #1
0
        public List <IdentityNavigation> GetByPage(IdentityNavigation filter, int currentPage, int pageSize)
        {
            //Common syntax
            var sqlCmd = @"M_Navigation_GetByPage";
            List <IdentityNavigation> listData = null;

            //For paging
            int offset = (currentPage - 1) * pageSize;

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@Status", filter.Active },
                { "@Offset", offset },
                { "@PageSize", pageSize }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters))
                    {
                        listData = ParsingListFromReader(reader);
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute M_Navigation_GetByPage. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(listData);
        }
Пример #2
0
        public IdentityNavigation GetById(int id)
        {
            //Common syntax
            var sqlCmd = @"Navigation_GetById";
            IdentityNavigation info = null;

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@Id", id }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters))
                    {
                        if (reader.Read())
                        {
                            info = ExtractNavigationData(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute Navigation_GetById. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(info);
        }
Пример #3
0
        public ActionResult Update(NavigationViewModels model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    if (!ModelState.IsValid)
                    {
                        string messages = string.Join("; ", ModelState.Values
                                                      .SelectMany(x => x.Errors)
                                                      .Select(x => x.ErrorMessage + x.Exception));
                        this.AddNotification(messages, NotificationType.ERROR);
                        return(View(model));
                    }
                }

                var identity = new IdentityNavigation();
                identity.Id       = model.Id;
                identity.ParentId = model.ParentId;
                identity.Active   = (model.Active) ? 1 : 0;
                //identity.Controller = model.Controller;
                //identity.Action = model.Action;
                identity.CssClass    = model.CssClass;
                identity.IconCss     = model.IconCss;
                identity.SortOrder   = model.SortOrder;
                identity.Name        = model.Name;
                identity.AbsoluteUri = model.AbsoluteUri;
                identity.Visible     = (model.Visible) ? 1 : 0;
                identity.Title       = model.Title;

                _mainStore.Update(identity);

                this.AddNotification(ManagerResource.LB_UPDATE_SUCCESS, NotificationType.SUCCESS);
            }
            catch (Exception ex)
            {
                this.AddNotification(ManagerResource.COMMON_ERROR_EXTERNALSERVICE_TIMEOUT, NotificationType.ERROR);
                logger.ErrorFormat("Failed to update because: {0}", ex.ToString());
            }

            return(RedirectToAction("Index"));
        }
Пример #4
0
        public int Insert(IdentityNavigation identity)
        {
            //Common syntax
            var sqlCmd = @"M_Navigation_Insert";
            var newId  = 0;

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@ParentId", identity.ParentId },
                { "@Area", identity.Area },
                { "@Name", identity.Name },
                { "@Title", identity.Title },
                { "@Desc", identity.Desc },
                { "@Action", identity.Action },
                { "@Controller", identity.Controller },
                { "@Visible", identity.Visible },
                { "@Authenticate", identity.Authenticate },
                { "@CssClass", identity.CssClass },
                { "@SortOrder", identity.SortOrder },
                { "@AbsoluteUri", identity.AbsoluteUri },
                { "@Active", identity.Active },
                { "@IconCss", identity.IconCss }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    var returnObj = MsSqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, sqlCmd, parameters);

                    newId = Convert.ToInt32(returnObj);
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute M_Navigation_Insert. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(newId);
        }
Пример #5
0
        private IdentityNavigation ExtractNavigationData(IDataReader reader)
        {
            List <IdentityNavigation> listData = listData = new List <IdentityNavigation>();
            var record = new IdentityNavigation();

            //Seperate properties;
            record.Id           = Utils.ConvertToInt32(reader["Id"]);
            record.ParentId     = Utils.ConvertToInt32(reader["ParentId"]);
            record.Area         = reader["Area"].ToString();
            record.Name         = reader["Name"].ToString();
            record.Title        = reader["Title"].ToString();
            record.Desc         = reader["Desc"].ToString();
            record.Action       = reader["Action"].ToString();
            record.Controller   = reader["Controller"].ToString();
            record.Visible      = Utils.ConvertToInt32(reader["Visible"]);
            record.Authenticate = Utils.ConvertToInt32(reader["Authenticate"]);
            record.CssClass     = reader["CssClass"].ToString();
            record.SortOrder    = Utils.ConvertToInt32(reader["SortOrder"]);
            record.AbsoluteUri  = reader["AbsoluteUri"].ToString();
            record.Active       = Utils.ConvertToInt32(reader["Active"]);
            record.IconCss      = reader["IconCss"].ToString();

            return(record);
        }
Пример #6
0
 public bool Update(IdentityNavigation identity)
 {
     return(myRepository.Update(identity));
 }
Пример #7
0
 public int Insert(IdentityNavigation identity)
 {
     return(myRepository.Insert(identity));
 }
Пример #8
0
 public List <IdentityNavigation> GetByPage(IdentityNavigation filter, int currentPage, int pageSize)
 {
     return(myRepository.GetByPage(filter, currentPage, pageSize));
 }