Пример #1
0
        public personModel createPerson(personModel pModel)
        {
            List <personModel> people = peopleFile.fullFilePath().loadpath().ConvertToPersonModel();
            int currentId             = 1;

            if (people.Count > 0)
            {
                currentId = people.OrderByDescending(x => x.Id).First().Id + 1;
            }
            pModel.Id = currentId;
            people.Add(pModel);

            people.savePeopleFile(peopleFile);

            return(pModel);
        }
Пример #2
0
        //TODO - implement perosn method

        public personModel createPerson(personModel pModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@Fname", pModel.Fname);
                p.Add("@Lname", pModel.Lname);
                p.Add("@EmailAddress", pModel.EmailAddress);
                p.Add("@phoneNumber", pModel.phoneNumber);
                p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
                connection.Execute("[Tournament].[dbo].[SpPeople_Insert]", p, commandType: CommandType.StoredProcedure);

                pModel.Id = p.Get <int>("@Id");

                return(pModel);
            }
        }