Esempio n. 1
0
        public async Task <DTO.ReturnResponse <DTO.MasterMap> > Add(DTO.MasterMap inMap, long personId)
        {
            var response = new DTO.ReturnResponse <DTO.MasterMap>();

            if (inMap.Columns.Count == 0)
            {
                response.Errors.Add("Zero Columns? Really?");
            }

            var mmap = _mapper.Map <MasterMap>(inMap);

            OrmHelper.SetAuditColumns(ref mmap, true, personId);

            var Headers  = new List <string>();
            var SqlNames = new List <string>();

            foreach (var col in mmap.Columns)
            {
                if (Headers.Contains(col.Header))
                {
                    response.Errors.Add($"Header not unique {col.Header}");
                }

                if (SqlNames.Contains(col.ColumnName))
                {
                    response.Errors.Add($"Header not unique {col.Header}");
                }

                if (response.Success)
                {
                    var tcol = col;
                    OrmHelper.SetAuditColumns(ref tcol, true, personId);
                }
            }

            if (response.Success)
            {
                try
                {
                    _db.MasterMap.Add(mmap);
                    await _db.SaveChangesAsync();

                    response.Result = _mapper.Map <DTO.MasterMap>(mmap);
                }
                catch (Exception ex)
                {
                    response.Errors.Add(ex.Message);
                }
            }

            return(response);
        }
Esempio n. 2
0
        public Task <DTO.ReturnResponse <DTO.MasterMap> > Update(DTO.MasterMap map, long personId)
        {
            var response = new DTO.ReturnResponse <DTO.MasterMap>();

            return(Task.FromResult(response));
        }