private void SaveDemotivatorToDatabase(string Name, string FirstString, string SecondString, string OriginalUrl, string ModifiedUrl)
 {
     Demotivators demotivator = new Demotivators();
     var CurrentUser = db.AspNetUsers.Find(User.Identity.GetUserId());
     demotivator.CreatorId = User.Identity.GetUserId();
     demotivator.Date = DateTime.Now;
     demotivator.Name = Name;
     demotivator.FirstString = FirstString;
     demotivator.SecondString = SecondString;
     demotivator.OriginalUrl = OriginalUrl;
     demotivator.ModifiedUrl = ModifiedUrl;
     demotivator.Rating = "0,0,0,0,0";
     db.Demotivators.Add(demotivator);
     CurrentUser.Demotivators.Add(demotivator);
     db.SaveChanges();
 }
        public async Task<ActionResult> SaveDemotivatorToCloud(string tag, Demotivators model)
        {
            string fileName = "";
            ImageUploadResult uploadResult = new ImageUploadResult();
            ImageUploadParams uploadParams = new ImageUploadParams();

            Account account = new Account(
                "lifedemotivator",
                "366978761796466",
                "WMYLmdaTODdm4U6VcUGhxapkcjI"
                );
            CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
            var upload = Request.Files[0];
            fileName = System.IO.Path.GetFileName(upload.FileName);
            upload.SaveAs(Server.MapPath("~/" + fileName));

            var TargetPath = Server.MapPath("~/" + fileName);
             uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(Server.MapPath("~/" + fileName)),
                PublicId = User.Identity.Name + fileName + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second,
            };
            uploadResult = cloudinary.Upload(uploadParams);
            System.IO.File.Delete(Server.MapPath("~/" + fileName));
            System.IO.File.Delete(Server.MapPath("~/img.png"));
            var OriginalUrl = uploadResult.Uri.ToString();

            uploadParams = new ImageUploadParams()
            {
                File = new FileDescription(path + "MyPicture.png"),
                PublicId = User.Identity.Name + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second,
            };
            uploadResult = cloudinary.Upload(uploadParams);
            System.IO.File.Delete(path + "MyPicture.png");

            var ModifiedUrl = uploadResult.Uri.ToString();

            SaveDemotivatorToDatabase(model.Name, model.FirstString , model.SecondString, OriginalUrl, ModifiedUrl);
            SaveTag(tag, db.Demotivators.ToList().Last().Id);
            return Redirect(Request.UrlReferrer.ToString());
        }