Esempio n. 1
0
        public BuildingSite AddNewSite(int userID, string siteName, string siteAddress, string image64)
        {
            BuildingSite site   = null;
            string       imgRef = uploadImg(image64);

            try
            {
                var result = Dal.AddNewSite(userID, siteName, siteAddress, imgRef);

                if (result == null)
                {
                    return(null);
                }


                site = new BuildingSite
                {
                    SiteId       = int.Parse(result.Rows[0]["siteID"].ToString()),
                    SiteName     = result.Rows[0]["siteName"].ToString(),
                    SiteAddress  = result.Rows[0]["siteAddress"].ToString(),
                    SiteStatus   = bool.Parse(result.Rows[0]["siteStatus"].ToString()),
                    UserTypeId   = int.Parse(result.Rows[0]["userTypeID"].ToString()),
                    UserTypeName = result.Rows[0]["userTypName"].ToString(),
                    SiteImage    = imgRef,
                    Rooms        = new List <Room>()
                };
                return(site);
            }


            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 2
0
        public BuildingSite AddNewSite(int userID, string siteName, string siteAddress)
        {
            var result = Dal.AddNewSite(userID, siteName, siteAddress);

            if (result == null)
            {
                return(null);
            }


            var site = new BuildingSite
            {
                SiteId       = int.Parse(result.Rows[0]["siteID"].ToString()),
                SiteName     = result.Rows[0]["siteName"].ToString(),
                SiteAddress  = result.Rows[0]["siteAddress"].ToString(),
                SiteStatus   = bool.Parse(result.Rows[0]["siteStatus"].ToString()),
                UserTypeId   = int.Parse(result.Rows[0]["userTypeID"].ToString()),
                UserTypeName = result.Rows[0]["userTypName"].ToString(),
                Rooms        = new List <Room>()
            };


            return(site);
        }