Example #1
0
 /// <remarks/>
 public void InserirContatoAsync(string authenticationKey, ContactModel model, object userState) {
     if ((this.InserirContatoOperationCompleted == null)) {
         this.InserirContatoOperationCompleted = new System.Threading.SendOrPostCallback(this.OnInserirContatoOperationCompleted);
     }
     this.InvokeAsync("InserirContato", new object[] {
                 authenticationKey,
                 model}, this.InserirContatoOperationCompleted, userState);
 }
Example #2
0
 public int Insert(string authenticationKey, ContactModel contact) {
     object[] results = this.Invoke("Insert", new object[] {
                 authenticationKey,
                 contact});
     return ((int)(results[0]));
 }
Example #3
0
 public int InserirContato(string authenticationKey, ContactModel model) {
     object[] results = this.Invoke("InserirContato", new object[] {
                 authenticationKey,
                 model});
     return ((int)(results[0]));
 }
Example #4
0
 /// <remarks/>
 public void InserirContatoAsync(string authenticationKey, ContactModel model) {
     this.InserirContatoAsync(authenticationKey, model, null);
 }
        public ActionResult NewContact(ContactModel model)
        {
            if (new WS.Promoter.Promoter().ValidateEmail(Settings.AutenticationKeyEarningSystem, model.Email)) return ValidationResult(Resources.Resource.GS_Contact_EmailAlreadyExist);
                

            using (var ws = Service)
            {
                var idPromoter = 0;
                var userAuth = FormsAuthenticationUtil.UserAuthenticated;
                if (userAuth != null && userAuth.IdCliente.HasValue)
                {
                    var promoter = new WS.Promoter.Promoter().GetPromoter(Settings.AutenticationKeyEarningSystem,
                                                                          userAuth.IdCliente.Value);
                    if (promoter != null)
                    {
                        idPromoter = promoter.IdPromoter;
                    }

                    model.IdPromoter = idPromoter;
                    model.Selecionado = true;
                    string validationMessage;

                    var contact = new ContactModel { IdPromoter = idPromoter, Email = model.Email, Name = model.Name };

                    if (ws.ValidarNovoContato(Settings.AutenticationKeyEarningSystem, contact, out validationMessage))
                        model.IdContact = ws.InserirContato(Settings.AutenticationKeyEarningSystem, contact);
                    else
                        return ValidationResult(validationMessage);
                }
            }

            AdicionarItemLista(model);

            return SuccessResult(Resources.Resource.Msg_Geral_CadastroRealizado);
        }
Example #6
0
 /// <remarks/>
 public void ValidarNovoContatoAsync(string authenticationKey, ContactModel model) {
     this.ValidarNovoContatoAsync(authenticationKey, model, null);
 }
Example #7
0
 /// <remarks/>
 public void ValidateEmailExistsAsync(string authenticationKey, ContactModel model) {
     this.ValidateEmailExistsAsync(authenticationKey, model, null);
 }
Example #8
0
 /// <remarks/>
 public void DeleleteAsync(string authenticationKey, ContactModel contact) {
     this.DeleleteAsync(authenticationKey, contact, null);
 }
Example #9
0
 /// <remarks/>
 public void SelectByFiltersAsync(string authenticationKey, ContactModel model) {
     this.SelectByFiltersAsync(authenticationKey, model, null);
 }
Example #10
0
 public bool ValidateEmailExists(string authenticationKey, ContactModel model) {
     object[] results = this.Invoke("ValidateEmailExists", new object[] {
                 authenticationKey,
                 model});
     return ((bool)(results[0]));
 }
Example #11
0
 public ContactModel[] SelectByFilters(string authenticationKey, ContactModel model) {
     object[] results = this.Invoke("SelectByFilters", new object[] {
                 authenticationKey,
                 model});
     return ((ContactModel[])(results[0]));
 }
        private void FilterByExample(ref List<ContactModel> itens, ContactModel example)
        {
            if (example == null)
                return;

            if (!string.IsNullOrWhiteSpace(example.Email))
            {
                itens = itens.Where(m => m.Email.ToLower().Contains(example.Email.ToLower())).ToList();
            }

            if (!string.IsNullOrWhiteSpace(example.Name))
            {
                itens = itens.Where(m => m.Name.ToLower().Contains(example.Name.ToLower())).ToList();
            }
        }
        private void AdicionarItemLista(ContactModel model)
        {
            if (model.IdContact <= default(int))
                return;

            var allItens = GetListFromSession();
            allItens.Add(model);
            SaveListInSession(allItens);
        }
Example #14
0
 /// <remarks/>
 public void InsertAsync(string authenticationKey, ContactModel contact) {
     this.InsertAsync(authenticationKey, contact, null);
 }
Example #15
0
 /// <remarks/>
 public void ValidateEmailExistsAsync(string authenticationKey, ContactModel model, object userState) {
     if ((this.ValidateEmailExistsOperationCompleted == null)) {
         this.ValidateEmailExistsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnValidateEmailExistsOperationCompleted);
     }
     this.InvokeAsync("ValidateEmailExists", new object[] {
                 authenticationKey,
                 model}, this.ValidateEmailExistsOperationCompleted, userState);
 }
Example #16
0
 public bool Delelete(string authenticationKey, ContactModel contact) {
     object[] results = this.Invoke("Delelete", new object[] {
                 authenticationKey,
                 contact});
     return ((bool)(results[0]));
 }
Example #17
0
 public bool ValidarNovoContato(string authenticationKey, ContactModel model, out string message) {
     object[] results = this.Invoke("ValidarNovoContato", new object[] {
                 authenticationKey,
                 model});
     message = ((string)(results[1]));
     return ((bool)(results[0]));
 }
Example #18
0
 /// <remarks/>
 public void DeleleteAsync(string authenticationKey, ContactModel contact, object userState) {
     if ((this.DeleleteOperationCompleted == null)) {
         this.DeleleteOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleleteOperationCompleted);
     }
     this.InvokeAsync("Delelete", new object[] {
                 authenticationKey,
                 contact}, this.DeleleteOperationCompleted, userState);
 }
        public JsonResult Create(string name, string email)
        {
            try
            {
                if (new WS.Promoter.Promoter().ValidateEmail(Settings.AutenticationKeyEarningSystem, email)) return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.GS_Contact_EmailAlreadyExist }, JsonRequestBehavior.AllowGet);

                if (SecurityHelper.GainSystemUserIsAuthenticated())
                {
                    var userAuth = FormsAuthenticationUtil.UserAuthenticated;

                    if (userAuth != null)
                    {
                        if (userAuth.IdCliente != null)
                        {
                            var promoter = new WS.Promoter.Promoter().GetPromoter(Settings.AutenticationKeyEarningSystem, userAuth.IdCliente.Value);

                            if (promoter != null)
                            {
                                var contact = new ContactModel
                                                  {
                                                      Name = name, 
                                                      Email = email, 
                                                      IdPromoter = promoter.IdPromoter
                                                  };

                                string validationMessage;
                                if (Service.ValidarNovoContato(Settings.AutenticationKeyEarningSystem, contact, out validationMessage))
                                {

                                    var idNewContact = new Contact().Insert(Settings.AutenticationKeyEarningSystem,
                                                                            contact);
                                    if (idNewContact != 0)
                                    {
                                        return
                                            Json(
                                                new JsonRequestResult
                                                    {
                                                        ResultType = JsonRequestResultType.Success,
                                                        Message = Resources.Resource.GS_Contact_Create_Success
                                                    },
                                                JsonRequestBehavior.AllowGet);
                                    }

                                    return
                                        Json(
                                            new JsonRequestResult
                                                {
                                                    ResultType = JsonRequestResultType.Error,
                                                    Message = Resources.Resource.GS_Contact_Create_Error
                                                },
                                            JsonRequestBehavior.AllowGet);
                                }
                                else
                                    return
                                        Json(
                                            new JsonRequestResult
                                            {
                                                ResultType = JsonRequestResultType.Error,
                                                Message = validationMessage
                                            },
                                            JsonRequestBehavior.AllowGet);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.Log("GS.ContactController.Create() :: Exception : ", ex);

                return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.GS_Contact_Create_Error }, JsonRequestBehavior.AllowGet);
            }

            return new JsonResult();
        }