internal void OnPersonSubscription(SubscriptionEventArgs eventArgs) { PersonSubscription?.Invoke(this, eventArgs); }
public async Task <IActionResult> CreateSubscribeAsync( [FromQuery] int idPlan ) { try { // captura login de usuario logado var login = Util .GetClaim(_httpContext, Constants.UserClaimIdentifier); // busca dados do usuario logado var user = await _userMananger .GetByLogin(login); // busca planos do usuario var plan = await _subscriptionMananger .GetByPersonAsyncNoTacking(user.Person.Id); // vefificar se usuario já tem plano if (plan != null) { return(BadRequest(new ResponseErrorViewModel { Status = Constants.Error, Errors = new List <object> { new { Message = Constants.SubscriptionInvalid } } })); } // buscar plano de acordo com id var subscription = await _subscriptionMananger .GetSubscriptionById(idPlan); if (subscription == null) { return(NotFound( new ResponseErrorViewModel { Status = Constants.Error, Errors = new List <object> { new { Message = Constants.InvalidPlan } } })); } var personSubscription = new PersonSubscription { Person = user.Person, IdPerson = user.Person.Id, Subscription = subscription, IdSubscription = subscription.Id, CreatedAt = Util.CurrentDateTime(), Validate = false }; await _subscriptionMananger .CreateAsync(personSubscription); _uow.Commit(); return(Created(new Uri( Url.ActionLink("CreateSubscribe", "Subscribe")), new ResponseViewModel { Result = null, Status = Constants.Sucess })); } catch (Exception ex) { // gerar log return(BadRequest(new ResponseErrorViewModel { Status = Constants.Error, Errors = new List <object> { Util.ReturnException(ex) } })); } }
public void RemoveAsync(PersonSubscription model) { throw new System.NotImplementedException(); }
public void Update(PersonSubscription model) { throw new System.NotImplementedException(); }
public Task CreateAsync(PersonSubscription model) { return(Task.Run(() => _context.PersonSubscription.Add(model))); }