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 <IActionResult> AddBid([FromBody] Model.BidOffer offer) { if (offer.UserId == 0) { offer.UserId = (int)HttpContext.Session.GetInt32("userid"); } var result = await _job.AddBid(offer); return(Ok(result)); }
public async Task <int> AddBid(Model.BidOffer offer) { int res = 0; try { await _db.BidOffer.AddAsync(offer); await _db.SaveChangesAsync(); return(1); } catch (Exception ex) { _logger.LogError(ex.Message); } return(res); }
public async Task <IActionResult> TakeJob([FromBody] Model.BidOffer offer) { var result = await _job.TakeJob(offer); return(Ok(result)); }