public void Upload <T>(T entity, IFormFile file, EImageType type) where T : BaseEntity, IHasImage { if (file == null) { return; } if (entity.Image != null) { Remove(entity.Image.PublicId); } var uploadResult = new ImageUploadResult(); using (var stream = file.OpenReadStream()) { var uploadParams = new ImageUploadParams() { File = new FileDescription(file.Name, stream) }; uploadResult = _cloudinary.Upload(uploadParams); } entity.Image.Type = type; entity.Image.Src = uploadResult.Uri.ToString(); entity.Image.PublicId = uploadResult.PublicId; }
public static string GetValue(EImageType type) { if (type == EImageType.Jpg) { return("jpg"); } if (type == EImageType.Jpeg) { return("jpeg"); } if (type == EImageType.Gif) { return("gif"); } if (type == EImageType.Png) { return("png"); } if (type == EImageType.Bmp) { return("bmp"); } if (type == EImageType.Unknown) { return("unknown"); } throw new Exception(); }
internal Logo(Guid id, string title, string path, EImageType imageType, Customer customer, DateTime? createdOn, Guid?createdByApplicationUserId, DateTime?lastUpdated, Guid?lastUpdatedByApplicationUserId, bool isDeleted, bool isActive) : base(id, title, path, createdOn, createdByApplicationUserId, lastUpdated, lastUpdatedByApplicationUserId, isDeleted, isActive) { base.ImageType = Enums.EImageType.LOGOTIPO; CustomerId = customer.Id; Customer = customer; }
/// <summary> /// Gets the correct EImageType based on the specified value (hashcode) /// </summary> /// <param name="value"></param> /// <returns></returns> public static EImageType EImageTypeFromValue(int value) { foreach (EImageType item in EImageType.GetValues(typeof(EImageType))) { if (item.GetHashCode() == value) { return(item); } } return(EImageType.Undefined); }
public static bool Equals(EImageType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower())) { return(true); } return(false); }
public void SetImageType(EImageType eImageType) { this.eImageType = eImageType; switch (this.eImageType) { case EImageType.FiveDay: bgImage.sprite = fiveDaySprite; break; case EImageType.Normal: bgImage.sprite = normalSprite; break; case EImageType.Today: bgImage.sprite = todaySprite; break; default: bgImage.sprite = todaySprite; break; } }
public ActionResult Index(string type, string Id) { DbDataContext db = new DbDataContext("CloudAppWebSite"); List <CImage> imageList = new List <CImage>(); int orgId = GetOrganizationId(); if (orgId == 0) { return(Redirect("/blog/Admin/Home/Index")); } int intId = Convert.ToInt32(Id); EImageType enumType = ((EImageType)Convert.ToInt32(type)); if (enumType == EImageType.Slider) { //ViewBag.SliderName = db.sl imageList = db.Images.Where(p => p.OrganizationId == orgId && p.ActiveStatus == EActiveStatus.Active && p.SliderId == intId).ToList(); } else if (enumType == EImageType.Text) { var texts = db.Texts.Where(p => p.Id == intId && p.OrganizationId == orgId && p.ActiveStatus == EActiveStatus.Active).FirstOrDefault(); if (texts.LanguageValues.FirstOrDefault(h => h.Lang == "TR") != null) { ViewBag.TextName = texts.LanguageValues.FirstOrDefault(h => h.Lang == "TR").Name; } else { ViewBag.TextName = ""; } imageList = db.Images.Where(p => p.OrganizationId == orgId && p.ActiveStatus == EActiveStatus.Active && p.TextId == intId).ToList(); } //if(enumType.) int intType = Convert.ToInt32(type); ViewBag.type = intType; ViewBag.id = intId; return(View(imageList)); }
public async Task <List <ImgPlayInfo> > GetAllImgPlaysAsync(int navigationID, EImageType imageType) { var res = await QueryListAsync("Type = @Type and NavigationID = @NavigationID", new { Type = (int)imageType, NavigationID = navigationID }, "Sort", asc : true); return(res.ToList()); }
public async Task <List <ImgPlayInfo> > GetImgPlaysAsync(int navigationID, EImageType imageType) { var res = await QueryListAsync("IsDisable =@IsDisable and Type = @Type and NavigationID = @NavigationID", new { IsDisable = (int)EYesOrNo.No, Type = (int)imageType, NavigationID = navigationID }, "Sort", asc : true); return(res.ToList()); }
public async Task <List <ImgPlayInfo> > GetImgPlayByTypeAsync(EImageType imageType) { var res = await QueryListAsync("IsDisable =@IsDisable and Type = @Type", new { IsDisable = (int)EYesOrNo.No, Type = (int)imageType }, "Sort", asc : true); return(res.ToList()); }
public int FindImage(string FileName, out int Width, out int Height, EImageType imgtype) { int index; if (imgtype == EImageType.IT_WALL) { STextureWAL TexWAL; if (CProgram.gQ2Game.gCMain.r_htic2 == false) { // load Quake2 WAL TexWAL = LoadWAL(FileName, out Width, out Height); } else { // load Heretic2 M8 TexWAL = LoadM8(FileName, out Width, out Height); } if (TexWAL.Tex2D != null) Textures.Add(TexWAL); return Textures.Count - 1; } else if (imgtype == EImageType.IT_SKY) { if (CProgram.gQ2Game.gCMain.r_htic2 == false) { Texture2D Tex2D; // load general image Tex2D = LoadSky("env\\" + FileName + ".tga", out Width, out Height); if (Tex2D != null) Skies.Add(Tex2D); } else { STextureWAL TexWAL; // load Heretic2 M8 TexWAL = LoadM8("pics\\skies\\" + FileName, out Width, out Height); if (TexWAL.Tex2D != null) Skies.Add(TexWAL.Tex2D); } return Skies.Count - 1; } else if (imgtype == EImageType.IT_PIC) { Texture2D Tex2D; Tex2D = LoadPic(FileName, out Width, out Height); Pictures.Add(Tex2D); return Pictures.Count - 1; } else { index = -1; Width = 0; Height = 0; } return index; }
public async Task <List <ImgPlayDto> > GetImgPlaysAsync(int navId, EImageType imageType) { var imgList = await Task.Run(() => imgPlayInfoRepository.GetImgPlaysAsync(navId, imageType)); return(ModelConvertUtil <ImgPlayInfo, ImgPlayDto> .ModelCopy(imgList)); }