Example #1
0
 public static PlayList Convert(PlayListDto playList)
 {
     return(new PlayList
     {
         Id = playList.Id,
         Name = playList.Name
     });
 }
Example #2
0
        public async Task <PlayListDto> CreatAsync(PlayListDto item)
        {
            var result = _context.PlayLists.Add(
                PlayListConverter.Convert(item));
            await _context.SaveChangesAsync();

            return(PlayListConverter.Convert(result.Entity));
        }
Example #3
0
        public ActionResult Put([FromBody] PlayListDto playListDto)
        {
            try
            {
                Response objResponse = new Response();

                var customerObj = db.playLists.FirstOrDefault(x => x.Id == playListDto.Id);
                if (customerObj == null)
                {
                    return(this.NotFound("Request doesnt exist"));
                }
                else
                {
                    if (!string.IsNullOrEmpty(playListDto.Image) && playListDto.Image.Contains("data:image"))
                    {
                        var dataparts = playListDto.Image.Split(',');
                        if (dataparts.Length > 1)
                        {
                            playListDto.Image = dataparts[1];
                        }

                        var    convertImage = Convert.FromBase64String(playListDto.Image);
                        string imageName    = playListDto.CustomerId + "-" + Guid.NewGuid().ToString();
                        // string filePath = Server.MapPath("~/Files/" + Path.GetFileName(imageName));
                        var filePath = Path.Combine("ClientApp/public/Images/Customers", imageName + ".png");
                        System.IO.File.WriteAllBytes(filePath, convertImage);
                        playListDto.Image = filePath.Replace("ClientApp/public", "");
                    }
                    customerObj.Name          = playListDto.Name;
                    customerObj.StartTime     = playListDto.StartTime;
                    customerObj.EndTime       = playListDto.EndTime;
                    customerObj.Description   = playListDto.Description;
                    customerObj.Image         = playListDto.Image;
                    customerObj.PerformerName = playListDto.PerformerName;
                    customerObj.Lamenter      = playListDto.Lamenter;
                    customerObj.EventPlace    = playListDto.EventPlace;
                    customerObj.IsActive      = playListDto.IsActive;
                    customerObj.Duration      = DateTime.Now;

                    db.playLists.Update(customerObj);
                    db.SaveChanges();
                }


                objResponse.Data    = customerObj;
                objResponse.Status  = true;
                objResponse.Message = " Edit Successfully";


                return(Ok(objResponse));
            }
            catch (Exception e)
            {
                writeException.Write(e.Message, DateTime.Now, "PlayList", "Put", "Admin");
                return(this.NotFound("Dosnt Edit successfully"));
            }
        }
Example #4
0
 public async Task <IActionResult> Put([FromBody] PlayListDto item)
 {
     try
     {
         return(Ok(await _repo.UpdateAsync(item)));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Example #5
0
        public async Task <bool> UpdateAsync(PlayListDto item)
        {
            if (item == null)
            {
                return(false);
            }
            _context.PlayLists.Update(PlayListConverter.Convert(item));
            await _context.SaveChangesAsync();

            return(true);
        }