Exemplo n.º 1
0
        public bool Update(IdentityGroupProperty identity)
        {
            //Common syntax
            var sqlCmd = @"M_GroupProperty_Update";

            //For parameters
            var parameters = new Dictionary <string, object>
            {
                { "@Id", identity.Id },
                { "@Name", identity.Name },
                { "@Icon", identity.Icon },
                { "@Status", identity.Status },
                { "@Description", identity.Description },
            };

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

            return(true);
        }
Exemplo n.º 2
0
        public IdentityGroupProperty GetById(int Id)
        {
            var info   = new IdentityGroupProperty();
            var sqlCmd = @"GroupProperty_GetById";

            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))
                    {
                        while (reader.Read())
                        {
                            info = ExtractGroupPropertyData(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute GroupProperty_GetGroupPropertyById. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }
            return(info);
        }
Exemplo n.º 3
0
        public int Insert(IdentityGroupProperty identity)
        {
            var newId  = 0;
            var sqlCmd = @"M_GroupProperty_Insert";

            var parameters = new Dictionary <string, object>
            {
                { "@Name", identity.Name },
                { "@Icon", identity.Icon },
                { "@Status", identity.Status },
                { "@Description", identity.Description },
                { "@CreatedBy", identity.CreatedBy }
            };

            try
            {
                using (var conn = new SqlConnection(_connectionString))
                {
                    var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters);
                    if (reader.Read())
                    {
                        newId = Utils.ConvertToInt32(reader[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to M_GroupProperty_Insert. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(newId);
        }
        private IdentityGroupProperty ExtractEditFormData(GroupPropertyEditModel formData)
        {
            var myIdetity = new IdentityGroupProperty();

            myIdetity.Id          = formData.Id;
            myIdetity.Name        = formData.Name;
            myIdetity.Description = formData.Description;
            myIdetity.Icon        = formData.Icon;
            myIdetity.Status      = formData.Status;

            return(myIdetity);
        }
        private GroupPropertyEditModel RenderEditModel(IdentityGroupProperty identity)
        {
            var editModel = new GroupPropertyEditModel();

            editModel.Id          = identity.Id;
            editModel.Name        = identity.Name;
            editModel.Description = identity.Description;
            editModel.Icon        = identity.Icon;
            editModel.Status      = identity.Status;
            editModel.LangList    = identity.LangList;

            return(editModel);
        }
        private IdentityGroupProperty ExtractCreateFormData(GroupPropertyCreateModel formData)
        {
            var myIdetity = new IdentityGroupProperty();

            myIdetity.Name        = formData.Name;
            myIdetity.Description = formData.Description;
            //myIdetity.UrlFriendly = UrlFriendly.ConvertToUrlFriendly(formData.Name);
            myIdetity.Icon      = formData.Icon;
            myIdetity.Status    = Utils.ConvertToInt32(formData.Status);
            myIdetity.CreatedBy = User.Identity.GetUserId();

            return(myIdetity);
        }
Exemplo n.º 7
0
        public IdentityGroupProperty GetDetail(int Id)
        {
            var info   = new IdentityGroupProperty();
            var sqlCmd = @"M_GroupProperty_GetDetail";

            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))
                    {
                        //Get base info
                        if (reader.Read())
                        {
                            info = ExtractGroupPropertyData(reader);
                        }

                        //Get data for all languages
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                var langItem = new IdentityGroupPropertyLang();
                                langItem.Id          = Utils.ConvertToInt32(reader["Id"]);
                                langItem.LangCode    = reader["LangCode"].ToString();
                                langItem.GroupName   = reader["GroupName"].ToString();
                                langItem.Description = reader["Description"].ToString();
                                langItem.GroupId     = Utils.ConvertToInt32(reader["GroupId"]);

                                info.LangList.Add(langItem);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute M_GroupProperty_GetDetail. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }
            return(info);
        }
        public ActionResult Index(ManageGroupPropertyModel model)
        {
            int currentPage = 1;
            int pageSize    = SystemSettings.DefaultPageSize;

            if (string.IsNullOrEmpty(model.SearchExec))
            {
                model.SearchExec = "Y";
                if (!ModelState.IsValid)
                {
                    ModelState.Clear();
                }
            }

            if (Request["Page"] != null)
            {
                currentPage = Utils.ConvertToInt32(Request["Page"], 1);
            }

            var filter = new IdentityGroupProperty
            {
                Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null,
                Status  = model.Status == null ? -1 : (int)model.Status
            };

            try
            {
                model.SearchResults = _mainStore.GetByPage(filter, currentPage, SystemSettings.DefaultPageSize);
                if (model.SearchResults != null && model.SearchResults.Count > 0)
                {
                    model.TotalCount  = model.SearchResults[0].TotalCount;
                    model.CurrentPage = currentPage;
                    model.PageSize    = pageSize;
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed to get data because: " + ex.ToString());

                return(View(model));
            }

            return(View(model));
        }
Exemplo n.º 9
0
        private IdentityGroupProperty ExtractGroupPropertyData(IDataReader reader)
        {
            var record = new IdentityGroupProperty();

            //Seperate properties
            record.Id          = Utils.ConvertToInt32(reader["Id"]);
            record.Name        = reader["Name"].ToString();
            record.Icon        = reader["Icon"].ToString();
            record.Description = reader["Description"].ToString();

            record.CreatedBy     = reader["CreatedBy"].ToString();
            record.CreatedDate   = reader["CreatedDate"] == DBNull.Value ? null : (DateTime?)reader["CreatedDate"];
            record.LastUpdated   = reader["LastUpdated"] == DBNull.Value ? null : (DateTime?)reader["LastUpdated"];
            record.LastUpdatedBy = reader["LastUpdatedBy"].ToString();
            record.Status        = Utils.ConvertToInt32(reader["Status"]);

            return(record);
        }
Exemplo n.º 10
0
        public List <IdentityGroupProperty> GetByPage(IdentityGroupProperty filter, int currentPage, int pageSize)
        {
            //Common syntax
            var sqlCmd = @"M_GroupProperty_GetByPage";
            List <IdentityGroupProperty> listData = null;

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

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

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

            return(listData);
        }
Exemplo n.º 11
0
 public bool Update(IdentityGroupProperty identity)
 {
     return(myRepository.Update(identity));
 }
Exemplo n.º 12
0
 public int Insert(IdentityGroupProperty identity)
 {
     return(myRepository.Insert(identity));
 }
Exemplo n.º 13
0
 public List <IdentityGroupProperty> GetByPage(IdentityGroupProperty filter, int currentPage, int pageSize)
 {
     return(myRepository.GetByPage(filter, currentPage, pageSize));
 }