Пример #1
0
        //Convert methods
        private static Program GetProgramFromProgramDetails(ProgramDetails record)
        {
            if (record == null)
                return null;
            else
            {
                var newProgram = new Program(record.ProgramID, record.Title, record.Abstract, record.BannerUrl,
                    record.CommentsCount, record.Body,
                    record.Requirements, record.ViewCount, record.DowmloadCount, record.Votes,
                    record.TotalRating, record.AddedBy, record.AddedDate, record.EnableComments,
                    record.OnlyForMembers, record.OnlyForAdmins, record.CategoryID, record.ProgramUrl, record.ProgramImageUrl,
                    record.CreatedBy, record.CreatedDate, record.CategoryTitle);

                newProgram.SizeMB = record.SizeMB.ToString("0.00");
                return newProgram;
            }
        }
Пример #2
0
        public static bool UpdateProgram(int id, string title, string Abstract, string bannerUrl, string body, string requirements,
            bool enableComments, bool OnlyForMembers, bool OnlyForAdmins, int categoryID, string programUrl, string programImageUrl, string createdBy, DateTime createdDate, string sizeMB)
        {
            title = BizObject.ConvertNullToEmptyString(title);
            Abstract = BizObject.ConvertNullToEmptyString(Abstract);
            body = BizObject.ConvertNullToEmptyString(body);
            requirements = BizObject.ConvertNullToEmptyString(requirements);
            programUrl = BizObject.ConvertNullToEmptyString(programUrl);
            programImageUrl = BizObject.ConvertNullToEmptyString(programImageUrl);
            createdBy = BizObject.ConvertNullToEmptyString(createdBy);
            bannerUrl = BizObject.ConvertNullToEmptyString(bannerUrl);

            if (createdDate == null)
            {
                createdDate = DateTime.Now;
            }

            ProgramDetails record = new ProgramDetails(id, title, Abstract, bannerUrl, 0, body, requirements, 0, 0, 0, 0, "", DateTime.Now,
                enableComments, OnlyForMembers, OnlyForAdmins, categoryID, programUrl, programImageUrl, createdBy, createdDate, "");
            decimal resultSize;
            if (!decimal.TryParse(sizeMB, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture , out resultSize))
            {
                if (!decimal.TryParse(sizeMB, System.Globalization.NumberStyles.AllowDecimalPoint, new System.Globalization.CultureInfo("ru-RU"), out resultSize))
                {
                    if (!decimal.TryParse(sizeMB, System.Globalization.NumberStyles.AllowDecimalPoint, new System.Globalization.CultureInfo("en-US"), out resultSize))
                    {
                        resultSize = 0;
                    }
                }
            }
            record.SizeMB = resultSize;
            bool ret = SiteProvider.Programs.UpdateProgram(record);

            BizObject.PurgeCacheItems("programs_program_" + id.ToString());
            BizObject.PurgeCacheItems("programs_programs");
            return ret;
        }
Пример #3
0
 public abstract int InsertProgram(ProgramDetails program);
Пример #4
0
 public abstract bool UpdateProgram(ProgramDetails program);
Пример #5
0
        protected virtual ProgramDetails GetProgramFromReader(IDataReader reader, bool readBody)
        {
            ProgramDetails program = new ProgramDetails(
               (int)reader["ProgramID"],
               reader["Title"].ToString(),
               reader["Abstract"].ToString(),
               (reader["BannerUrl"] == DBNull.Value ? "":reader["BannerUrl"].ToString()),
               (int)reader["CommentsCount"],
               null,
               reader["Requirements"].ToString(),
               (int)reader["ViewCount"],
               (int)reader["DownloadCount"],
               (int)reader["Votes"],
               (int)reader["TotalRating"],
               reader["AddedBy"].ToString(),
               (DateTime)reader["AddedDate"],
               (bool)reader["EnableComments"],
               (bool)reader["OnlyForMembers"],
               (bool)reader["OnlyForAdmins"],
               (int)reader["CategoryID"],
               reader["ProgramUrl"].ToString(),
               reader["ProgramImageUrl"].ToString(),
               reader["CreatedBy"].ToString(),
               (DateTime)reader["CreatedDate"],
               reader["CategoryTitle"].ToString());

            if (readBody)
                program.Body = reader["Body"].ToString();

            if (reader["SizeMB"] != null && reader["SizeMB"] != DBNull.Value)
            {
                program.SizeMB = (decimal)reader["SizeMB"];
            }

            return program;
        }