// POST: api/Coopan public IHttpActionResult Post([FromBody] AddUserCoopanModel model) { int userId = 3; var res = objCoopanRepo.SubmitCoopan(model); if (res) { var data = objCoopanRepo.GetAllTickets(userId); return(Ok(data)); } return(Ok(false)); }
public bool SubmitCoopan(AddUserCoopanModel model) { using (CashCoopanEntities1 db = new CashCoopanEntities1()) { var isExits = db.tblUserTickets.Where(x => x.ticketId == model.TicketId && x.userId == model.UserId && x.status == (int?)CoopanStatus.Completed).FirstOrDefault(); if (isExits == null) { tblUserTicket dbModel = new tblUserTicket(); dbModel.ticketId = model.TicketId; dbModel.userId = model.UserId; dbModel.ticketDate = DateTime.UtcNow; dbModel.status = (int?)CoopanStatus.Completed; db.tblUserTickets.Add(dbModel); db.SaveChanges(); return(true); } return(false); } }