public static tbl_platform FromPlatformDataContractToTblPlatform(PlatformDataContract platformData)
        {
            if (platformData.PlatformId < 1 || string.IsNullOrEmpty(platformData.PlatformName))
            {
                return(null);
            }

            return(new tbl_platform
            {
                id = platformData.PlatformId,
                platform_name = platformData.PlatformName
            });
        }
        public static bool Compare(PlatformDataContract obj1, PlatformDataContract obj2)
        {
            if (obj1 == null && obj2 == null)
            {
                return(true);
            }

            if (obj1 == null && obj2 != null)
            {
                return(false);
            }

            if (obj1 != null && obj2 == null)
            {
                return(false);
            }

            return(obj1.PlatformId == obj2.PlatformId &&
                   string.Equals(obj1.PlatformName.Trim(), obj2.PlatformName.Trim(),
                                 StringComparison.CurrentCultureIgnoreCase));
        }
Пример #3
0
        public Result <PlatformDataContract[]> GetPlatform(PlatformDataContract platformFilter)
        {
            var result = new Result <PlatformDataContract[]>();

            try
            {
                using (var ctx = new PolicyProjectEntities())
                {
                    if (platformFilter == null)
                    {
                        result.SomeResult =
                            ctx.tbl_platform.Select(
                                platformTblData => new PlatformDataContract
                        {
                            PlatformId   = platformTblData.id,
                            PlatformName = platformTblData.platform_name
                        }).ToArray();
                    }
                    else
                    {
                        result.SomeResult = ctx.tbl_platform.Where(x => x.id == platformFilter.PlatformId)
                                            .Select(platformTblData => new PlatformDataContract
                        {
                            PlatformId   = platformTblData.id,
                            PlatformName = platformTblData.platform_name
                        })
                                            .ToArray();
                    }

                    result.BoolRes = true;
                }
            }
            catch (Exception ex)
            {
                result.BoolRes  = false;
                result.ErrorRes = string.Concat("Ошибка получения списка платформ. ", ex.Message);
            }

            return(result);
        }
Пример #4
0
        public string GetPlatformRest(PlatformDataContract platformFilter)
        {
            var queryResult = GetPlatform(platformFilter);

            return(JsonConvert.SerializeObject(queryResult));
        }