public bool Save(TaskRegisterViewModel model, Guid idAccount)
        {
            var task = ConvertTask.FromTaskRegisterViewModel(model);

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

            task.IdAccount = idAccount;
            task.Branch    = null;
            task.Campaign  = null;
            task.Merchant  = null;
            task.Answers   = null;

            if (string.IsNullOrEmpty(task.Code))
            {
                var code = _sequenceBusiness.NextSequence(CTask.SequenceCode, idAccount).ToString();
                task.Code = code;
            }

            _taskCampaignDao.InsertOrUpdate(task);
            //SaveTask(task, idAccount);
            return(true);
        }
        public TaskRegisterViewModel GetTask(Guid?idCampaign, Guid idTask, Guid idAccount)
        {
            var itemResult = new TaskRegisterViewModel();

            //Creo Tarea
            if (idTask == Guid.Empty && idCampaign != null)
            {
                var campaign = _campaignDao.GetOne(idCampaign.Value, idAccount);
                itemResult.CampaignName = campaign.Name;
                itemResult.IdCampaign   = idCampaign.Value;
            }
            //Recupero Tarea
            else if (idTask != Guid.Empty)
            {
                var task     = _taskCampaignDao.GetTaskByIdForRegisterPage(idTask, idAccount);
                var campaign = _campaignDao.GetOne(task.IdCampaign, idAccount);
                itemResult = ConvertTask.ToTaskRegisterViewModel(task);
                itemResult.CampaignName = campaign.Name;
                itemResult.IdCampaign   = task.IdCampaign;
            }
            //Mala Invocación de método
            else
            {
                throw new ExceptionMardis("Se ha invocado de manera incorrecta a la tarea");
            }

            return(itemResult);
        }
예제 #3
0
 public static TaskCampaign FromTaskRegisterViewModel(TaskRegisterViewModel model)
 {
     return(new TaskCampaign()
     {
         Description = model.Description,
         DateModification = DateTime.Now,
         Id = model.Id,
         IdBranch = model.IdBranch,
         StartDate = model.StartDate,
         IdCampaign = model.IdCampaign,
         IdMerchant = model.IdMerchant,
         IdStatusTask = model.IdStatusTask,
         Code = model.Code,
         DateCreation = model.DateCreation.Year > 2010? model.DateCreation:DateTime.Now,
         Route = model.Route,
         AggregateUri = model.AggregateUri,
         ExternalCode = model.ExternalCode,
         UserValidator = model.UserValidator,
         DateValidation = model.DateValidation.Year > 2010 ? model.DateCreation : DateTime.Now
     });
 }
예제 #4
0
        public IActionResult Register(TaskRegisterViewModel model, string returnUrl = null)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    GetMerchants();
                    return(View(model));
                }

                _taskCampaignBusiness.Save(model, ApplicationUserCurrent.AccountId);

                if (!string.IsNullOrEmpty(model.ReturnUrl))
                {
                    return(Redirect(model.ReturnUrl));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                _logger.LogError(new EventId(0, "Error Index"), e.Message);
                return(RedirectToAction("Index", "StatusCode", new { statusCode = 1 }));
            }
        }