Esempio n. 1
0
        public async Task <ExecutionStatus <Category> > Run(CategoryId categoryId)
        {
            using var connection = new SqliteConnection
                                       (_geekLemonContext.ConnectionString);

            var q = @"SELECT Id, DisplayName, Name,
                WhatWeAreLookingFor,UniqueId ,Version  FROM Categories
                Where Id = @Id";

            try
            {
                var r = await connection.
                        QueryFirstOrDefaultAsync <CategoryTemp>
                            (q, new
                {
                    @Id = categoryId.Value,
                });

                var rmaped = _mapper.Map <Category>(r);

                return(ExecutionStatus <Category> .DbIfDefaultThenError(rmaped));
            }
            catch (Exception ex)
            {
                return(ExecutionStatus <Category> .DbError(ex));
            }
        }
Esempio n. 2
0
        public async Task <ExecutionStatus <JudgeIds> > Run(Judge entity)
        {
            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            var q = @"INSERT INTO Judges 
                (Login, Password, BirthDate, Name_First,
                 Name_Last,CategoryID,
                UniqueId, Version )
                VALUES(@Login, @Password, @BirthDate, 
                @Name_First, @Name_Last, @CategoryId, @UniqueId,@Version);

                SELECT seq From sqlite_sequence Where Name='Judges'";

            //var v = GetValuesFromJugde(entity);

            //var result = await connection.QueryAsync<int>(q,
            //     new
            //     {
            //         @Id = entity.Id,
            //         @Login = entity.Login,
            //         @Password = entity.Password,
            //         @BirthDate = v.Birthdate,
            //         @Name_First = entity.Name.First,
            //         @Name_Last = entity.Name.Last,
            //         @Email_ForeConference = v.EmailForeConference,
            //         @Email_ForSpeakers = v.EmailForSpeakers,
            //         @Phone_ForSpekers = v.PhoneForSpekers,
            //         @Phone_ForConference = v.PhoneForConference,
            //         @CategoryID = entity.Category.Id.Value
            //     });

            var temp = _mapper.Map <JudgeTemp>(entity);

            try
            {
                var result = await connection.QueryAsync <int>(q, temp);

                int createdId = result.FirstOrDefault();

                JudgeIds ids = new JudgeIds()
                {
                    CreatedId = new JudgeId(createdId),
                    UniqueId  = entity.UniqueId
                };

                return(ExecutionStatus
                       <JudgeIds> .
                       DbIfDefaultThenError(ids));
            }
            catch (Exception ex)
            {
                return(ExecutionStatus <JudgeIds>
                       .DbError(ex.Message));
            }
        }
Esempio n. 3
0
        public async Task <ExecutionStatus <IReadOnlyList <Category> > > Run()
        {
            using var connection = new SqliteConnection
                                       (_geekLemonContext.ConnectionString);

            try
            {
                var r = await connection.QueryAsync <CategoryTemp>
                            (@"SELECT Id, DisplayName, Name ,
                WhatWeAreLookingFor,UniqueId ,Version FROM Categories;");

                var rmaped = _mapper.Map <IEnumerable <Category> >(r);

                return(ExecutionStatus <IReadOnlyList <Category> >
                       .DbIfDefaultThenError
                           (rmaped.ToList().AsReadOnly()));
            }
            catch (Exception ex)
            {
                return(ExecutionStatus <IReadOnlyList <Category> >
                       .DbError(ex));
            }
        }