public IHttpActionResult PutINSCRICAO(int id, INSCRICAO iNSCRICAO) { if (id != iNSCRICAO.COD_INSCRICAO) { return(BadRequest()); } db.Entry(iNSCRICAO).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!INSCRICAOExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult add_kind_date_timeToDB(int idCustomer, string kind, int Time, DateTime date) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Order o = DB.Order.Add(new Order { CustomerId = idCustomer, OrderDate = DateTime.Now, MorningOrEvening = Time, EventDate = date, EventKind = kind }); DB.SaveChanges(); return(Ok(o)); }
public JsonResult SaveUrlaub(Events e) { var status = false; using (EventsEntities dc = new EventsEntities()) { if (e.EventID > 0) { ///Update the event var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault(); if (v != null) { v.Subject = e.Subject; v.Start = e.Start; v.End = e.End; v.Description = e.Description; v.ThemeColor = e.ThemeColor; } } else { dc.Events.Add(e); } dc.SaveChanges(); SendVerificationLinkEmail(); status = true; } return(new JsonResult { Data = new { status = status } }); }
public JsonResult SaveEvent(Events a) { var status = false; using (EventsEntities db = new EventsEntities()) { if (a.EventId > 0) { var evnt = db.Events.Where(b => b.EventId == a.EventId).FirstOrDefault(); if (evnt != null) { evnt.EventName = a.EventName; evnt.StartTime = a.StartTime; evnt.EndTime = a.EndTime; } } else { db.Events.Add(a); } db.SaveChanges(); status = true; } return(new JsonResult { Data = new { status } }); }
public IHttpActionResult addMenuToEventOrder(Mc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DB.Menu.Add(menu); DB.SaveChanges(); return(Ok(menu)); }
public IHttpActionResult PutEVENTO(int id, EVENTO eVENTO) { var existingEntity = db.EVENTO.First(x => x.COD_EVENTO == eVENTO.COD_EVENTO); existingEntity.TITULO = eVENTO.TITULO; existingEntity.DESCRICAO = eVENTO.DESCRICAO; existingEntity.DATA = eVENTO.DATA; existingEntity.HORARIO = eVENTO.HORARIO; existingEntity.DURACAO = eVENTO.DURACAO; existingEntity.VAGAS = eVENTO.VAGAS; existingEntity.IMAGEM_URL = eVENTO.IMAGEM_URL; existingEntity.ATIVO = 1; if (id != existingEntity.COD_EVENTO) { return(BadRequest()); } else { db.Entry(existingEntity).State = EntityState.Modified; } db.Entry(existingEntity).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EVENTOExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutUSUARIO(int id, USUARIO uSUARIO) { var existingEntity = db.USUARIO.First(x => x.COD_USUARIO == uSUARIO.COD_USUARIO); existingEntity.ATIVO = 1; existingEntity.NOME = uSUARIO.NOME; existingEntity.EMAIL = uSUARIO.EMAIL; existingEntity.CELULAR = uSUARIO.CELULAR; existingEntity.COD_PERFIL = uSUARIO.COD_PERFIL; if (id != existingEntity.COD_USUARIO) { return(BadRequest()); } else if (existingEntity.SENHA == uSUARIO.SENHA) { db.Entry(existingEntity).Property(x => x.SENHA).IsModified = false; } else { existingEntity.SENHA = Encrypt.CalculateMD5Hash(uSUARIO.SENHA); db.Entry(existingEntity).State = EntityState.Modified; } try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!USUARIOExists(id)) { return(NotFound()); } else { throw new DbUpdateConcurrencyException(); } } return(StatusCode(HttpStatusCode.NoContent)); }
// POST api/<controller> public IHttpActionResult addPaymentToEventOrder(PayMents payment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DB.PayMents.Add(payment); DB.SaveChanges(); return(Ok(payment)); }
private void frmNewEdit_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { if (string.IsNullOrEmpty(txtEventType.Text)) { MessageBox.Show("Please enter Event Type.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEventType.Focus(); e.Cancel = true; return; } db.SaveChanges(); //saving changes to new or edited Event if pass above condition e.Cancel = false; } e.Cancel = false; }
//btn Delete and Try catch example(catch was called when trying to delete when no records) private void btnDelete_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are You sure want to delete this record ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { db.EventsTable.Remove(eventsTableBindingSource.Current as EventsTable); eventsTableBindingSource.RemoveCurrent(); db.SaveChanges(); } } catch (ArgumentNullException) { MessageBox.Show("There is nothing to Delete", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public JsonResult DeleteEvent(int eventId) { var status = false; using (EventsEntities db = new EventsEntities()) { var ev = db.Events.Where(a => a.EventId == eventId).FirstOrDefault(); if (ev != null) { db.Events.Remove(ev); db.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status } }); }
public JsonResult DeleteUrlaub(int EventID) { /// <summary> /// Implements the DeleteEvent method. /// </summary> /// <returns>Memeful Comments</returns> /// <image url="https://media.giphy.com/media/Ca7gy6EZqdH32/giphy.gif" scale="0.3" /> var status = false; using (EventsEntities dc = new EventsEntities()) { var v = dc.Events.Where(a => a.EventID == EventID).FirstOrDefault(); if (v != null) { dc.Events.Remove(v); dc.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }