Пример #1
0
        public async Task <IActionResult> PutShortner(int id, Shortner shortner)
        {
            if (id != shortner.ID)
            {
                return(BadRequest());
            }

            _context.Entry(shortner).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShortnerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public static string GetURL()
        {
            string URL  = "";
            Random rand = new Random();
            // run the loop till I get a string of 10 characters

            //posibility of characters count
            int posibilitycount = characters.Count;

            for (int i = 0; i < characters.Count - 1; i++)
            {
                posibilitycount = posibilitycount * characters.Count;
            }
            //Add new character in list
            int newcharposition = 0;

            if ((posibilitycount - 5) < count)
            {
                newcharposition = characters.Count - 4;
                char newchar = characters[newcharposition];
                characters.Add(newchar);

                //Add new character
                ShortCharacters shortcharacter = new ShortCharacters();
                shortcharacter.Id = 1;
                var shortcharentity = _context.ShortCharacters.Find(shortcharacter.Id);
                shortcharentity.Characters = shortcharentity.Characters + "," + newchar;
                _context.Entry(shortcharentity).CurrentValues.SetValues(shortcharentity);
                _context.SaveChanges();
            }


            for (int i = 0; i < characters.Count; i++)
            {
                // Get random numbers, to get either a character or a number...
                //int random = rand.Next(0, 3);
                int random = rand.Next(0, characters.Count);
                URL += characters[random].ToString();
            }
            return(URL);
        }
Пример #3
0
 public void Edit(Registration updatedUrl)
 {
     _ctx.Entry(updatedUrl).State = EntityState.Modified;
     SaveAll();
 }
Пример #4
0
 public void Edit(PaymentTransaction payment)
 {
     _ctx.Entry(payment).State = EntityState.Modified;
     _ctx.SaveChanges();
 }
 public void Edit(Entities.AdManage updatedAd)
 {
     _ctx.Entry(updatedAd).State = EntityState.Modified;
     SaveAll();
 }
 public void Edit(Entities.UrlShortner updatedUrl)
 {
     _ctx.Entry(updatedUrl).State = EntityState.Modified;
     SaveAll();
 }