Exemple #1
0
        public ReturnModel CreateCard([FromBody] CardModel model, long idLine, string accesToken)
        {
            var account =
                _readOnlyRepository.First <Account>(
                    account1 => account1.Token == accesToken);

            ReturnModel remodel = new ReturnModel();

            if (account != null)
            {
                if (account.VerifyToken(account))
                {
                    Lines line        = _readOnlyRepository.GetById <Lines>(idLine);
                    Cards card        = _mappingEngine.Map <CardModel, Cards>(model);
                    Cards cardCreated = _writeOnlyRepository.Create(card);
                    if (cardCreated != null)
                    {
                        line.AddCard(cardCreated);
                        var      lineUpdate = _writeOnlyRepository.Update(line);
                        Activity activity   = new Activity();
                        activity.Text = account.FirstName + " Creo una card en " + line.Title;
                        account.AddActivities(activity);
                        var accountUpdate = _writeOnlyRepository.Update(account);
                        return(remodel.ConfigureModel("Successfull", "Se creo correctamente la card " + cardCreated.Text, remodel));
                    }
                    return(remodel.ConfigureModel("Error", "No se pudo crear la card", remodel));
                }
                return(remodel.ConfigureModel("Error", "Su session ya expiro", remodel));
            }
            return(remodel.ConfigureModel("Error", "No se pudo acceder a la cuenta", remodel));
        }