//Guardar Promotores public bool GuardarPromotor(Promotores promotor) { try { Regex inv = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); if (!inv.IsMatch(promotor.Email)) { throw new FaultException("Email incorrecto"); } using (var db = new NtLinkLocalServiceEntities()) { if (promotor.IdPromotor == 0) { if (db.Promotores.Any(p => p.Email == promotor.Email)) { throw new FaultException("Email Duplicado"); } db.Promotores.AddObject(promotor); } else { var o = db.Promotores.Where(p => p.IdPromotor == promotor.IdPromotor).FirstOrDefault(); db.Promotores.ApplyCurrentValues(promotor); } db.SaveChanges(); return(true); } } catch (FaultException fe) { throw; } catch (Exception ee) { Logger.Error(ee.Message); if (ee.InnerException != null) { Logger.Error(ee.InnerException); } return(false); } }
public IActionResult Put([FromBody] Promotores promotores, int id) { try { if (id > 0 && id == promotores.ID) { _promotoresRepository.Update(promotores); } else { return(BadRequest("Informe o id")); } return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public Promotores Delete([FromBody] Promotores Promotor) { Promotor.IdEstatus = 2; Promotor.Actualizar(); return(Promotor); }
public Promotores Update([FromBody] Promotores Promotor) { Promotor.Actualizar(); return(Promotor); }
public Promotores Add([FromBody] Promotores Promotor) { Promotor.Agregar(); return(Promotor); }