コード例 #1
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        public IdentityPlace GetPlaceById(int Id, bool getShort = false)
        {
            //Common syntax
            var           sqlCmd = @"Place_GetPlaceById";
            IdentityPlace record = 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))
                    {
                        record = new IdentityPlace();
                        if (reader.Read())
                        {
                            record = ExtractPlaceData(reader, getShort);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute Place_GetPlaceByUrl. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(record);
        }
コード例 #2
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        public IdentityPlace GetById(int Id)
        {
            var info   = new IdentityPlace();
            var sqlCmd = @"Place_GetPlaceById";

            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 = ExtractPlaceData(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute Place_GetPlaceById. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }
            return(info);
        }
コード例 #3
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        private IdentityPlace ExtractPlaceData(IDataReader reader, bool getShort = false)
        {
            var record = new IdentityPlace();

            //Seperate properties
            record.Id         = Utils.ConvertToInt32(reader["Id"]);
            record.GName      = reader["GName"].ToString();
            record.GFullName  = reader["GFullName"].ToString();
            record.GId        = reader["GId"].ToString();
            record.GLat       = reader["GLat"].ToString();
            record.GLong      = reader["GLong"].ToString();
            record.GUrl       = reader["GUrl"].ToString();
            record.Icon       = reader["Icon"].ToString();
            record.ProvinceId = Utils.ConvertToInt32(reader["ProvinceId"]);
            record.DistrictId = Utils.ConvertToInt32(reader["DistrictId"]);

            if (!getShort)
            {
                record.GType    = reader["GType"].ToString();
                record.GPlaceId = reader["GPlaceId"].ToString();
                record.Province = reader["Province"].ToString();
                record.District = reader["District"].ToString();
                record.RawData  = reader["RawData"].ToString();
            }

            record.Status            = Utils.ConvertToInt32(reader["Status"]);
            record.PostCount         = Utils.ConvertToInt32(reader["PostCount"]);
            record.PostCountProvince = Utils.ConvertToInt32(reader["PostCountProvince"]);
            record.Cover             = reader["Cover"].ToString();

            return(record);
        }
コード例 #4
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        public bool Update(IdentityPlace identity)
        {
            //Common syntax
            var sqlCmd = @"M_Place_Update";

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

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

            return(true);
        }
コード例 #5
0
        private PlaceEditModel RenderEditModel(IdentityPlace identity)
        {
            var editModel = new PlaceEditModel();

            editModel.Id     = (int)identity.Id;
            editModel.Name   = identity.GName;
            editModel.Cover  = identity.Cover;
            editModel.Status = identity.Status;

            return(editModel);
        }
コード例 #6
0
        private IdentityPlace ExtractEditFormData(PlaceEditModel formData)
        {
            var myIdetity = new IdentityPlace();

            myIdetity.Id     = formData.Id;
            myIdetity.GName  = formData.Name;
            myIdetity.Cover  = formData.Cover;
            myIdetity.Status = formData.Status;

            return(myIdetity);
        }
コード例 #7
0
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        //public ActionResult Delete_Confirm(int id)
        //{
        //    var strError = string.Empty;
        //    if (id <= 0)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }

        //    try
        //    {
        //        _mainStore.Delete(id);
        //        //Clear cache
        //        PlaceServices.ClearPlaceCache();
        //    }
        //    catch (Exception ex)
        //    {
        //        strError = ManagerResource.LB_SYSTEM_BUSY;

        //        logger.Error("Failed to get Delete Place because: " + ex.ToString());

        //        return Json(new { success = false, message = strError });
        //    }

        //    return Json(new { success = true, message = ManagerResource.LB_DELETE_SUCCESS, title = ManagerResource.LB_NOTIFICATION });
        //}

        #region Helpers

        private IdentityPlace ExtractCreateFormData(PlaceCreateModel formData)
        {
            var myIdetity = new IdentityPlace();

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

            return(myIdetity);
        }
コード例 #8
0
        //[AccessRoleChecker]
        public ActionResult Index(ManagePlaceModel 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 IdentityPlace
            {
                Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null,
                Status  = model.Status == null ? -1 : (int)model.Status
            };

            try
            {
                model.SearchResults = _mainStore.GetAll(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));
        }
コード例 #9
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        public int Insert(IdentityPlace identity, string language)
        {
            var newId  = 0;
            var sqlCmd = @"Place_Insert";

            var parameters = new Dictionary <string, object>
            {
                { "@GName", identity.GName },
                { "@GFullName", identity.GFullName },
                { "@GType", identity.GType },
                { "@GPlaceId", identity.GPlaceId },
                { "@GId", identity.GId },
                { "@GLat", identity.GLat },
                { "@GLong", identity.GLong },
                { "@GUrl", identity.GUrl },
                { "@Icon", identity.Icon },
                { "@RawData", identity.RawData },
                { "@Province", identity.Province },
                { "@District", identity.District },
                { "@IsProvince", identity.IsProvince },
                { "@Languages", language }
            };

            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 Place_Insert. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(newId);
        }
コード例 #10
0
ファイル: RpsPlace.cs プロジェクト: vuadaphop3z/manager
        public List <IdentityPlace> GetAll(IdentityPlace filter, int currentPage, int pageSize)
        {
            //Common syntax
            var sqlCmd = @"M_Place_GetByPage";
            List <IdentityPlace> 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 = ParsingListPlaceFromReader(reader);
                    }
                }
            }
            catch (Exception ex)
            {
                var strError = "Failed to execute M_Place_GetByPage. Error: " + ex.Message;
                throw new CustomSQLException(strError);
            }

            return(listData);
        }
コード例 #11
0
ファイル: StorePlace.cs プロジェクト: vuadaphop3z/manager
 public bool Update(IdentityPlace identity)
 {
     return(myRepository.Update(identity));
 }
コード例 #12
0
ファイル: StorePlace.cs プロジェクト: vuadaphop3z/manager
 public int Insert(IdentityPlace identity, string language)
 {
     return(myRepository.Insert(identity, language));
 }
コード例 #13
0
ファイル: StorePlace.cs プロジェクト: vuadaphop3z/manager
 public List <IdentityPlace> GetAll(IdentityPlace filter, int currentPage, int pageSize)
 {
     return(myRepository.GetAll(filter, currentPage, pageSize));
 }