Пример #1
0
        //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);
            }
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
 public Promotores Delete([FromBody] Promotores Promotor)
 {
     Promotor.IdEstatus = 2;
     Promotor.Actualizar();
     return(Promotor);
 }
Пример #4
0
 public Promotores Update([FromBody] Promotores Promotor)
 {
     Promotor.Actualizar();
     return(Promotor);
 }
Пример #5
0
 public Promotores Add([FromBody] Promotores Promotor)
 {
     Promotor.Agregar();
     return(Promotor);
 }