Ejemplo n.º 1
0
        public ActionResult SaveImageFromURLWithDelete(string url, string idToDelete)
        {
            try
            {
                var idToDeleteInt = GenericLogic.GetInt(idToDelete);
                if (idToDeleteInt > 0)
                {
                    try
                    {
                        var CurrentImage = db.Images.FirstOrDefault(I => I.CalorieImageID == idToDeleteInt);
                        if (CurrentImage != null)
                        {
                            db.Images.Remove(CurrentImage);
                            db.SaveChanges();
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                }


                var ID = ImageLogic.GetAndSaveImageFromURL(url, CalorieImage.ImageType.UserImage);
                return(Content(ID.ToString(), "text/xml"));
            }
            catch
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Content("", MediaTypeNames.Text.Plain));
            }
        }
Ejemplo n.º 2
0
 public ActionResult SaveImageFromURL(string url)
 {
     try
     {
         var ID = ImageLogic.GetAndSaveImageFromURL(url, CalorieImage.ImageType.UserImage);
         return(Content(ID.ToString(), "text/xml"));
     }
     catch
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(Content("", MediaTypeNames.Text.Plain));
     }
 }