public async Task <IActionResult> PutProfileItem(string id, ProfileItem profileItem)
        {
            HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);

            if (id != profileItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutProfiles([FromRoute] string id, [FromBody] Profiles profiles)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != profiles.ProCardId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutProfile(long id, Profile profile)
        {
            if (id != profile.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IHttpActionResult> PutProfile(int id, Profile profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != profile.ProfileID)
            {
                return(BadRequest());
            }

            db.Entry(profile).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task EliminarUsuarioAsync(int codigo)
        {
            Usuario user = new Usuario()
            {
                Codigo = codigo
            };

            _db.Entry(user).State = EntityState.Deleted;
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "ID,FIRSTNAME,LASTNAME,BIRTHDAY,CITY,STATE,VETSTATUS,OCCUPATION,FAMILY,BIO,USERID,PROFILECREATED")] Profile profile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(profile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("MyProfile"));
     }
     return(View(profile));
 }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "Id,ChatId,Name")] Profile profile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(profile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(profile));
 }
Beispiel #8
0
 public ActionResult Edit([Bind(Include = "FIRSTNAME,LASTNAME,BIRTHDAY,LOCATION,VETSTATUS,OCCUPATION,FAMILY,BIO")] Profile profile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(profile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(profile));
 }
Beispiel #9
0
        public async Task <GithubProfile> GetAsync(long id)
        {
            var entity = await _context
                         .Set <GithubProfile>()
                         .FirstOrDefaultAsync(o => o.Id == id);

            if (entity == null)
            {
                entity = _context
                         .Set <GithubProfile>()
                         .Local
                         .FirstOrDefault(o => o.Id == id);
            }
            if (entity != null)
            {
                await _context.Entry(entity).ReloadAsync();
            }

            return(entity);
        }
Beispiel #10
0
        public override async Task Execute(Message message, TelegramBotClient client)
        {
            var     chatId  = message.Chat.Id;
            Profile profile = db.Profiles.Where(p => p.ChatId == chatId).FirstOrDefault();

            switch (profile.CurrentProperty)
            {
            case "Name":
                Regex regex = new Regex(@"^[a-zA-Zа-яА-Я']{1,50}[ ][a-zA-Zа-яА-Я']{1,50}$");
                Match match = regex.Match(message.Text);
                profile.Name            = message.Text;
                profile.CurrentProperty = "Email";
                db.Entry(profile).State = EntityState.Modified;
                await client.SendTextMessageAsync(chatId, "Your Email:");

                await db.SaveChangesAsync();

                break;

            case "Email":
                regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                match = regex.Match(message.Text);
                if (match.Success)
                {
                    profile.Email           = message.Text;
                    profile.CurrentProperty = "PhoneNumber";
                    db.Entry(profile).State = EntityState.Modified;
                    await client.SendTextMessageAsync(chatId, "Your Phone Number:");

                    await db.SaveChangesAsync();
                }
                else
                {
                    await client.SendTextMessageAsync(chatId, "Somethink wrong, please try again)))");
                }
                break;

            case "PhoneNumber":
                regex = new Regex(@"^\+?([0-9]{2})?[ ]?[-. \(]?([0-9]{3})[-. \)]?[ ]?([0-9]{2})[-. ]?([0-9]{2})[-. ]?([0-9]){3}$");
                match = regex.Match(message.Text);
                if (match.Success)
                {
                    profile.Phone           = message.Text;
                    profile.CurrentProperty = "Adress";
                    db.Entry(profile).State = EntityState.Modified;
                    await client.SendTextMessageAsync(chatId, "Your Adress(City):");

                    await db.SaveChangesAsync();
                }
                else
                {
                    await client.SendTextMessageAsync(chatId, "Somethink wrong, please try again)))");
                }
                break;

            case "Adress":
                regex = new Regex(@"^[a-zA-Zа-яА-ЯіІїЄ']{1,50}[- ]?[a-zA-Zа-яА-ЯіІї']{1,50}?$");
                match = regex.Match(message.Text);
                if (match.Success)
                {
                    profile.Adress          = message.Text;
                    profile.CurrentProperty = "Position";
                    db.Entry(profile).State = EntityState.Modified;
                    await client.SendTextMessageAsync(chatId, "Your current position");

                    await db.SaveChangesAsync();
                }
                else
                {
                    await client.SendTextMessageAsync(chatId, "Somethink wrong, please try again)))");
                }
                break;

            case "Position":
                profile.CurrentPosition = message.Text;
                profile.CurrentProperty = "Experience";
                db.Entry(profile).State = EntityState.Modified;
                await client.SendTextMessageAsync(chatId, "Your experience");

                await db.SaveChangesAsync();

                break;

            case "Experience":
                profile.Experience      = message.Text;
                profile.CurrentProperty = "End";
                db.Entry(profile).State = EntityState.Modified;
                await client.SendTextMessageAsync(chatId, "thank you for attention");

                await db.SaveChangesAsync();

                break;

            default:
                await client.SendTextMessageAsync(chatId, "We already have your profile");

                break;
            }
        }