예제 #1
0
        //Update general content found in the website
        public bool saveGeneralInfo(GeneralInfoQuery info)
        {
            try
            {
                //Check dates are valid
                String conferenceDay1 = "";
                String conferenceDay2 = "";
                String conferenceDay3 = "";

                if (info.dateFrom == "" && info.dateTo != "")
                {
                    return false;
                }

                else if (info.dateFrom != "" && info.dateTo == "")
                {
                    conferenceDay1 = info.dateFrom;
                }

                else if (info.dateFrom != "" && info.dateTo != "" && info.dateFrom.Split('/').Count() > 2 && info.dateTo.Split('/').Count() > 2)
                {
                    //check distance between dates

                    //string from = Convert.ToDateTime(info.dateFrom).ToShortDateString();
                    //string to = Convert.ToDateTime(info.dateTo).ToShortDateString();

                    var fromDay = Convert.ToInt32(info.dateFrom.Split('/')[1]);
                    var fromMonth = Convert.ToInt32(info.dateFrom.Split('/')[0]);
                    var fromYear = Convert.ToInt32(info.dateFrom.Split('/')[2]);

                    var toDay = Convert.ToInt32(info.dateTo.Split('/')[1]);
                    var toMonth = Convert.ToInt32(info.dateTo.Split('/')[0]);
                    var toYear = Convert.ToInt32(info.dateTo.Split('/')[2]);

                    // Constructor (Year, Month, Day)

                    DateTime dateFrom = new DateTime(fromYear, fromMonth, fromDay);
                    DateTime dateTo = new DateTime(toYear, toMonth, toDay);

                    double differenceDays = dateTo.Subtract(dateFrom).TotalDays;

                    //Depending on the difference assign 1, 2 or 3 conference days
                    if (differenceDays < 0 || differenceDays >= 3)
                    {
                        return false;
                    }

                    else if (differenceDays == 0)
                    {
                        conferenceDay1 = info.dateFrom;
                    }

                    else if (differenceDays == 1)
                    {
                        conferenceDay1 = info.dateFrom;
                        conferenceDay2 = info.dateTo;
                    }
                    else if (differenceDays == 2)
                    {
                        conferenceDay1 = info.dateFrom;
                        DateTime d2 = dateFrom.AddDays(1);
                        var month = d2.Month; var day = d2.Day; var year = d2.Year;
                        conferenceDay2 = month + "/" + day + "/" + year;
                        conferenceDay3 = info.dateTo;
                    }
                }

                using (conferenceadminContext context = new conferenceadminContext())
                {
                    this.saveInterfaceElement("conferenceAcronym", info.conferenceAcronym);

                    this.saveInterfaceElement("conferenceName", info.conferenceName);

                    this.saveInterfaceElement("conferenceDay1", conferenceDay1);

                    this.saveInterfaceElement("conferenceDay2", conferenceDay2);

                    this.saveInterfaceElement("conferenceDay3", conferenceDay3);

                    var logo = (from s in context.interfacedocuments
                                where s.attibuteName == "logo"
                                select s).FirstOrDefault();

                    if (logo != null && info.logo != null && info.logo != "")
                        logo.content = info.logo;

                    context.SaveChanges();
                    return true;
                }
            }
            catch (Exception ex)
            {
                Console.Write("WebManger.saveGeneralInfo error " + ex);
                return false;
            }
        }
예제 #2
0
        //Get general content found in the conference
        public GeneralInfoQuery getGeneralInfo()
        {
            try
            {
                GeneralInfoQuery info = new GeneralInfoQuery();
                info.conferenceAcronym = this.getInterfaceElement("conferenceAcronym").content;
                info.conferenceName = this.getInterfaceElement("conferenceName").content;
                info.dateFrom = this.getInterfaceElement("conferenceDay1").content;
                info.dateTo = this.getInterfaceElement("conferenceDay3").content;

                if (info.dateTo == "")
                {
                    info.dateTo = this.getInterfaceElement("conferenceDay2").content;
                }

                return info;
            }
            catch (Exception ex)
            {
                Console.Write("WebManager.getGeneralInfo error " + ex);
                return null;
            }
        }
예제 #3
0
        //Get conference logo
        public GeneralInfoQuery getWebsiteLogo()
        {
            try
            {
                GeneralInfoQuery logo = new GeneralInfoQuery();
                using (conferenceadminContext context = new conferenceadminContext())
                {

                    var img = (from s in context.interfacedocuments
                               where s.attibuteName == "logo"
                               select s).FirstOrDefault();

                    if (img != null)
                    {
                        logo.logo = img.content;
                    }
                }

                return logo;
            }
            catch (Exception ex)
            {
                Console.Write("WebManager.getWebsiteLogo error " + ex);
                return null;
            }
        }