public TaskCampaign SaveTaskRegister(string inputTask, Guid idAccount)
        {
            TaskCampaign result;
            var          taskModelView = JSonConvertUtil.Deserialize <TaskRegisterModelView>(inputTask);
            var          task          = new TaskCampaign()
            {
                IdAccount    = idAccount,
                IdBranch     = taskModelView.IdBranch,
                IdCampaign   = taskModelView.IdCampaign,
                IdMerchant   = taskModelView.IdMerchant,
                IdStatusTask = taskModelView.IdStatusTask,
                Description  = taskModelView.Description,
                StartDate    = taskModelView.StartDate,
                Campaign     = null,
                Branch       = null
            };

            if (taskModelView.IdStatusTask == Guid.Empty)
            {
                var status = _statusTaskBusiness.GeStatusTaskByName(CTask.StatusPending);
                task.IdStatusTask = status.Id;
            }

            using (var transaccion = Context.Database.BeginTransaction())
            {
                try
                {
                    if (string.IsNullOrEmpty(task.Code))
                    {
                        var nextSequence = _sequenceBusiness.NextSequence(CTask.SequenceCode,
                                                                          idAccount);

                        task.Code = nextSequence.ToString();
                    }

                    var stateRegister = EntityState.Added;

                    if (Guid.Empty != task.Id)
                    {
                        stateRegister = EntityState.Modified;
                    }

                    Context.TaskCampaigns.Add(task);

                    Context.Entry(task).State = stateRegister;

                    //graba cambios en COntexto
                    Context.SaveChanges();
                    transaccion.Commit();
                    result = GetTaskByIdForRegisterPage(task.Id, idAccount);
                }
                catch
                {
                    transaccion.Rollback();
                    result = null;
                }
            }

            return(result);
        }
        protected List <FilterValue> GetFilters(string filterValues, bool deleteFilter)
        {
            List <FilterValue> filters;

            if (string.IsNullOrEmpty(filterValues))
            {
                SetSessionVariable("filter", "");
            }

            if (deleteFilter)
            {
                filters = JSonConvertUtil.Deserialize <List <FilterValue> >(filterValues);
            }
            else
            {
                var filter = JSonConvertUtil.Deserialize <FilterValue>(filterValues);

                filters = JSonConvertUtil.Deserialize <List <FilterValue> >(GetSessionVariable("filter"));

                if (filters == null)
                {
                    filters = new List <FilterValue>();
                }

                if (filter != null)
                {
                    filters.Add(filter);
                }
            }

            SetSessionVariable("filter", JSonConvertUtil.Convert(filters));

            return(filters);
        }
Beispiel #3
0
        public async void _SaveAnswerQuestionComplete(String _model, string Idtask)
        {
            int resp              = 0;
            var _task             = JSonConvertUtil.Deserialize <MyTaskViewModel>(_model);
            var _questionModel    = new List <MyTaskQuestionsViewModel>();
            var _questionModelSub = new List <MyTaskQuestionsViewModel>();

            foreach (var _question in _task.ServiceCollection.First().ServiceDetailCollection)
            {
                _questionModel.AddRange(_question.QuestionCollection.Where(x => x.CodeTypePoll == "COMPLETE"));
            }
            foreach (var _question in _task.ServiceCollection.First().ServiceDetailCollection)
            {
                foreach (var _seccion in _question.Sections)
                {
                    _questionModelSub.AddRange(_seccion.QuestionCollection.Where(x => x.CodeTypePoll == "COMPLETE"));
                }
            }

            var _union = ((from a in _questionModel select a)
                          .Union
                              (from a in _questionModelSub select a)).ToList();

            if (_union.Count() > 0)
            {
                _taskCampaignBusiness.CreateAnswerComplete(_union, Guid.Parse(Idtask), ApplicationUserCurrent.AccountId, Guid.Parse(ApplicationUserCurrent.UserId));
            }
        }
Beispiel #4
0
        public JsonResult Save(string task)
        {
            try
            {
                var model = JSonConvertUtil.Deserialize <MyTaskViewModel>(task);

                if (model == null)
                {
                    return(null);
                }
                if (ApplicationUserCurrent.UserId == null)
                {
                    ApplicationUserCurrent.UserId    = Convert.ToString(Global.UserID);
                    ApplicationUserCurrent.AccountId = Global.AccountId;
                    ApplicationUserCurrent.ProfileId = Global.ProfileId;
                    ApplicationUserCurrent.PersonId  = Global.PersonId;
                }
                _taskCampaignBusiness.SaveAnsweredPoll(model, ApplicationUserCurrent.AccountId, ApplicationUserCurrent.ProfileId, Guid.Parse(ApplicationUserCurrent.UserId), model.IdStatusTask, "");

                return(Json("OK"));
            }
            catch (Exception e)
            {
                _logger.LogError(new EventId(0, "Error Index"), e.Message);
                return(null);
            }
        }
        public IActionResult SaveRegister(string branch, string returnUrl = null)
        {
            try
            {
                var model = JSonConvertUtil.Deserialize <BranchRegisterViewModel>(branch);
                TryValidateModel(model);

                if (!ModelState.IsValid)
                {
                    return(null);
                }

                _branchBusiness.Save(model, ApplicationUserCurrent.AccountId);
                if (string.IsNullOrEmpty(model.ReturnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                return(Redirect(model.ReturnUrl));
            }
            catch (Exception e)
            {
                _logger.LogError("Error al guardar datos de local: " + e.Message, null);
                return(null);
            }
        }
        public IActionResult Index(string filterValues, int pageSize = 15, int pageIndex = 1)
        {
            var filters   = JSonConvertUtil.Deserialize <List <FilterValue> >(filterValues);
            var viewModel = _customerBusiness.GetPaginatedCustomers(filters, pageSize, pageIndex, ApplicationUserCurrent.AccountId);

            return(View(viewModel));
        }
        public JsonResult DeleteAccounts(string selectedAccounts)
        {
            var results = JSonConvertUtil.Deserialize <string[]>(selectedAccounts);

            _branchBusiness.DeleteAccounts(results);

            return(Json("ok"));
        }
Beispiel #8
0
        public JsonResult AddSection(string task, string idSection)
        {
            var model = JSonConvertUtil.Deserialize <MyTaskViewModel>(task);

            //  _taskCampaignBusiness.AddSection(model, ApplicationUserCurrent.AccountId, ApplicationUserCurrent.ProfileId, Guid.Parse(ApplicationUserCurrent.UserId), Guid.Parse(idSection));
            //model = _taskCampaignBusiness.GetSectionsPoll(model.IdTask, _idAccount,idSection);
            //return RedirectToAction("Profile", new { idTask = model.IdTask });
            return(Json(model));
        }
        public async Task <JsonResult> GuardarPredios(String ModelJson, String IdArea)
        {
            var user = await _userManager.GetUserAsync(User);

            var _model = JSonConvertUtil.Deserialize <List <PredioViewModel> >(ModelJson);

            _AreaProspeccionDAO.GuardarPredidios(_model, user.UserName, int.Parse(IdArea));
            return(Json(""));
        }
        public IActionResult Save(string service)
        {
            var model = JSonConvertUtil.Deserialize <ServiceRegisterViewModel>(service);

            TryValidateModel(model);

            if (!ModelState.IsValid)
            {
                return(null);
            }
            _serviceBusiness.Save(model, ApplicationUserCurrent.AccountId);
            return(RedirectToAction("Index"));
        }
Beispiel #11
0
 public IActionResult SelectBranches()
 {
     try
     {
         var filters = JSonConvertUtil.Deserialize <List <FilterValue> >(GetSessionVariable("filter"));
         var model   = _campaignBusiness.GetBranchesSelected(ApplicationUserCurrent.AccountId, filters);
         return(RedirectToAction("ImportBranches", model));
     }
     catch (Exception e)
     {
         _logger.LogError(new EventId(0, "Error Index"), e.Message);
         return(RedirectToAction("Index", "StatusCode", new { statusCode = 1 }));
     }
 }
 public JsonResult Save(string poll, string Comment)
 {
     try
     {
         var model = JSonConvertUtil.Deserialize <PedidoModel>(poll);
         _pedidosBusiness.SavePedido(model, "");
         return(Json(model));
     }
     catch (Exception ex)
     {
         _logger.LogError(new EventId(0, "Error Index"), ex.Message);
         return(null);
     }
 }
        public async Task <IActionResult> LoadProductNutriAxios(GetFacturaViewModel _data)
        {
            try
            {
                var model = JSonConvertUtil.Deserialize <FactNutriViewModel>(_data.urlfile);
                List <FactNutriViewModel> _model = new List <FactNutriViewModel>();
                _model.Add(model);

                var data = _taskCampaignBusiness.DataFactXml(_model, _data.IdAccount, null, null, null, null, false);

                if (data.status == "OK")
                {
                    reply.status  = "Ok";
                    reply.messege = "Item Guardado";
                    reply.data    = 1;
                }
                else
                {
                    reply.status  = data.messege;
                    reply.messege = data.error;
                    reply.data    = data;
                }
                return(Ok(reply));
            }
            catch (Exception e)
            {
                IList <TaskMigrateResultViewModel> data = new List <TaskMigrateResultViewModel>();
                data.Add(new TaskMigrateResultViewModel {
                    description = e.Message, Element = "0", Code = "0"
                });
                var rows = from x in data
                           select new
                {
                    description = x.description,
                    data        = x.Element,
                    Code        = x.Code
                };

                var jsondata = rows.ToArray();
                reply.data    = jsondata;
                reply.status  = "Fail";
                reply.messege = "Item no se Guardo";
                reply.data    = data;
                return(Ok(reply));
            }
        }
 public JsonResult SaveAnswerQuestion(String AnswerQuestion, String fintransaccion, String Idtask, String idstatus, String CodigoGemini)
 {
     try
     {
         var model = JSonConvertUtil.Deserialize <List <MyTaskViewAnswer> >(AnswerQuestion);
         if (model == null)
         {
             return(null);
         }
         _taskCampaignBusiness.CrearAnswerQuestion(model, ApplicationUserCurrent.AccountId, Guid.Parse(ApplicationUserCurrent.UserId), ApplicationUserCurrent.ProfileId, fintransaccion, Idtask, Guid.Parse(idstatus), CodigoGemini);
         return(Json(model));
     }
     catch (Exception ex)
     {
         _logger.LogError(new EventId(0, "Error Index"), ex.Message);
         return(null);
     }
 }
Beispiel #15
0
        public JsonResult SaveAnswerQuestion(String AnswerQuestion, String fintransaccion, String Idtask, String idstatus, String CodigoGemini, String task, String comment)
        {
            try
            {
                var model = JSonConvertUtil.Deserialize <List <MyTaskViewAnswer> >(AnswerQuestion);

                //var varmodel=model_2.ServiceCollection.First().ServiceDetailCollection.Where(x=>x.QuestionCollection.)
                _SaveAnswerQuestionComplete(task, Idtask);

                if (model == null)
                {
                    return(null);
                }
                _taskCampaignBusiness.CrearAnswerQuestion(model, ApplicationUserCurrent.AccountId, Guid.Parse(ApplicationUserCurrent.UserId), ApplicationUserCurrent.ProfileId, fintransaccion, Idtask, Guid.Parse(idstatus), CodigoGemini, comment);

                return(Json(model));
            }
            catch (Exception ex)
            {
                _logger.LogError(new EventId(0, "Error Index"), ex.Message);
                return(null);
            }
        }
        public JsonResult Save(string poll, string comment)
        {
            try
            {
                var model    = JSonConvertUtil.Deserialize <PedidoModel>(poll);
                var _comment = JSonConvertUtil.Deserialize <string>(comment);

                var idStatusTaskPrevio = model.tarea.IdStatusTask.ToString();

                _pedidosBusiness.SavePedido(model, _comment);

                if (idStatusTaskPrevio != model.IdStatusTask)
                {
                    _pedidosBusiness.EnvioCorreo(idStatusTaskPrevio.ToUpper(), model.IdStatusTask.ToUpper(), model);
                }

                return(Json(model));
            }
            catch (Exception ex)
            {
                _logger.LogError(new EventId(0, "Error Index"), ex.Message);
                return(null);
            }
        }