Beispiel #1
0
        public async Task <int> TakeJob(Model.BidOffer offer)
        {
            int res = 0;

            try
            {
                var off = await _db.JobOffer.Where(x => x.Id == offer.JobOfferId).FirstOrDefaultAsync();

                if (off != null)
                {
                    var edited = new Model.JobOffer();
                    edited           = off;
                    edited.TakenById = offer.User.Id;
                    edited.Status    = 2;
                    _db.Entry(off).CurrentValues.SetValues(edited);
                    _db.JobOffer.Update(off);
                    //await _db.TakenOffer.AddAsync(offer);
                    await _db.SaveChangesAsync();

                    return(1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(res);
        }
        public async Task <Users> Update(Users user)
        {
            var res = new Users();

            try
            {
                var Editeduser = _db.Users.Where(x => x.Id == user.Id).FirstOrDefault();
                if (Editeduser != null)
                {
                    _db.Entry(Editeduser).CurrentValues.SetValues(user);
                    _db.Users.Update(Editeduser);
                    await _db.SaveChangesAsync();

                    return(Editeduser);
                }
                else
                {
                    res = user;
                    return(res);
                }
            }

            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
            return(res);
        }