public override void MapFromTableRow(DataRow row) { ImageControl oImgCtrl = new ImageControl(); try { this.Id = row["Id"].ToString(); this.Title = row["Title"].ToString(); this.Text = row["Text"].ToString(); this.CreatedBy = row["CreatedBy"].ToString(); this.Category = row["Category"].ToString(); this.Type = row["Type"].ToString(); this.Image = row["Id"].ToString(); this.Status = row["Status"].ToString(); this.CreateDate = (DateTime)row["CreateDate"]; this.AlterDate = (DateTime)row["AlterDate"]; } catch (Exception e) { //throw; this.isValid = false; this.sMsgError.Add("Error: Event.MapFromTableRow."); this.sMsgError.Add(e.Message); return; } this.Validate(); this.Image = oImgCtrl.RetrieveImage("classifieds", this.Image); }
public override void MapFromTableRow(DataRow row) { try { this.Id = row["Id"].ToString(); this.Name = row["Name"].ToString(); this.Description = row["Description"].ToString(); this.StartDate = (DateTime)row["StartDate"]; this.EndDate = (DateTime)row["EndDate"]; this.Published = (bool)row["Published"]; this.StartPublishDate = (DateTime)row["StartPublishDate"]; this.EndPublishDate = (DateTime)row["EndPublishDate"]; this.Image = row["Image"].ToString(); this.Finished = (bool)row["Finished"]; this.MaxSlots = (int)row["MaxSlots"]; this.CurSlots = (int)row["CurSlots"]; this.CreatedBy = row["CreatedBy"].ToString(); this.Type = (int)row["Type"]; this.ExternalLink = row["ExternalLink"].ToString(); this.Title = row["Title"].ToString(); this.SubTitle = row["SubTitle"].ToString(); this.Text1 = row["Text1"].ToString(); this.Text2 = row["Text2"].ToString(); this.Footer = row["Footer"].ToString(); this.HeadImg = row["HeadImg"].ToString(); this.Location = row["Location"].ToString(); this.CreateDate = (DateTime)row["CreateDate"]; this.AlterDate = (DateTime)row["AlterDate"]; this.Status = row["Status"].ToString(); } catch (Exception e) { //throw; this.isValid = false; this.sMsgError.Add("Error: Event.MapFromTableRow."); this.sMsgError.Add(e.Message); return; } this.Validate(); ImageControl oImgCtrl = new ImageControl(); //this.Image = this.AdjustImageFile("events", this.Image); //this.HeadImg = this.AdjustImageFile("events", this.HeadImg); this.Image = oImgCtrl.RetrieveImage("events", this.Id + "-D"); this.HeadImg = oImgCtrl.RetrieveImage("events", this.Id + "-H"); }
public override void MapFromTableRow(DataRow row) { try { this.Id = row["Id"].ToString(); this.FirstName = row["FirstName"].ToString(); this.LastName = row["LastName"].ToString(); this.Email = row["Email"].ToString(); this.Gender = row["Gender"].ToString(); this.MaritalStatus = row["MaritalStatus"].ToString(); this.AgeRange = row["AgeRange"].ToString(); this.Education = row["Education"].ToString(); this.NearestIntersection = row["NearestIntersection"].ToString(); this.PostalCode = row["PostalCode"].ToString(); this.ConsentToContact = (bool)row["ConsentToContact"]; this.DateCreated = (DateTime)row["DateCreated"]; this.LastModified = (DateTime)row["LastModified"]; this.Status = row["Status"].ToString(); this.IsImmigrant = (bool)row["IsImmigrant"]; this.Picture = row["Picture"].ToString(); this.PictureName = row["Picture"].ToString(); } catch (Exception e) { //throw; this.isValid = false; this.sMsgError.Add("Error: UserDetails.MapFromTableRow."); this.sMsgError.Add(e.Message); return; } ImageControl ImgCtrl = new ImageControl(); //this.Picture = this.AdjustImageFile("users", this.Id); this.Picture = ImageContainer.RetrieveImagePath("users", this.Picture); this.Validate(); }
public async Task <bool> UpdateAvatar(ImageFile imageFile) { DateTime dDateNow = DateTime.Now; Dictionary <string, object> infoParameters = new Dictionary <string, object>(); ImageControl ImgCtrl = new ImageControl(); infoParameters.Add("Id", this.Id); infoParameters.Add("pictureName", imageFile.FileName); var imDelTsk = ImgCtrl.DeleteImageAsync("users", this.Picture); var imgUpdTsk = ImgCtrl.UploadImageAsync(imageFile); var imgUpd = false; var imgDel = false; var tableUpd = false; try { DataTable oUserData = DBConn.ExecuteCommand("sp_UserDetails_UpdateAvatar", infoParameters).Tables[0]; if (oUserData.HasErrors) { this.sMsgError.Add(oUserData.GetErrors().ToString()); tableUpd = false; } tableUpd = true; imgDel = await imDelTsk; imgUpd = await imgUpdTsk; } catch (Exception error) { this.sMsgError.Add(error.Message); return(false); } return(imgUpd && tableUpd); }
public override bool Update() { DateTime dNow = DateTime.Now; DataTable oClassDB; Dictionary <string, object> infoParameters = new Dictionary <string, object>(); Byte[] oImageBytes; int nIndex = 0; string cRegexp = @"\/(.*)"; string contentType = "image/"; Match oMatch; ImageControl oImgCtrl = new ImageControl(); ImageFile oImage; if (this.ImageData != null && this.ImageData.Length > 0) { //Image upload to BLOB Azure Storage nIndex = this.ImageData.IndexOf(";base64,"); if (nIndex >= 0) { try { oMatch = Regex.Match(this.ImageData.Substring(0, nIndex), cRegexp); oImageBytes = Convert.FromBase64String(this.ImageData.Substring(nIndex + 8)); contentType += oMatch.Value.ToString().Replace("/", "").Replace(";", ""); //oImgCtrl = new ImageControl(); //oImgCtrl.UploadImage("classifieds",this.Id, oImageBytes, contentType); infoParameters.Add("cImage", this.Id); } catch (Exception e) { return(false); } } else { infoParameters.Add("cImage", "square-image.png"); //Default Image for Classifieds } } else { infoParameters.Add("cImage", "square-image.png"); //Default Image for Classifieds } infoParameters.Add("cId", this.Id); infoParameters.Add("cTitle", this.Title); infoParameters.Add("cText", this.Text); infoParameters.Add("cCreatedBy", this.CreatedBy); infoParameters.Add("cCategory", this.Category); infoParameters.Add("cType", this.Type); infoParameters.Add("dAlterDate", dNow); try { oClassDB = DBConn.ExecuteCommand("sp_Classifieds_Update", infoParameters).Tables[0]; if (!oClassDB.HasErrors) { if (!oClassDB.HasErrors) { this.AlterDate = dNow; //this.Image = this.AdjustImageFile("classifieds", this.Image); this.Image = oImgCtrl.RetrieveImage("classifieds", this.Image); return(true); } else { this.sMsgError.Add("Error Updating Classified."); } } } catch (Exception e) { this.sMsgError.Add("Error Updating Classified."); this.sMsgError.Add(e.Message); } return(false); }