Beispiel #1
0
        /// <summary>
        /// Crear registro de Sancion
        /// Autor: Jair Guerrero
        /// Fecha: 2020-08-06
        /// </summary>
        public long Create(DocumentsAM entity)
        {
            try
            {
                var sancion = mapper.Map <Documents>(entity);

                IRepository <Documents> repo = new DocumentRepo(context);
                return(repo.Create(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Beispiel #2
0
        private DocumentsAM UploadFile(IFormFile formFile, string filePath, long type)
        {
            string userId = HttpContext.Session.GetString("IdUsers");

            byte[] fileByte = System.IO.File.ReadAllBytes(filePath);

            DocumentsAM doc = new DocumentsAM
            {
                Name             = formFile.FileName,
                Hash             = Guid.NewGuid().ToString(),
                IdUser           = userId,
                Size             = (formFile.Length) / 1024,
                Pages            = NumberPages(filePath),
                RegistrationDate = DateTime.Now,
                IdState          = 5,
                IdDocType        = type
            };

            doc.Contents = Encrypt(fileByte, key, IV);

            return(doc);
        }
Beispiel #3
0
        public IActionResult CreateDoc([FromBody] DocumentsAM data)
        {
            try
            {
                ConsecutiveConfigAM consecutive = null;

                if (data.IdDocType == 1)
                {
                    consecutive = configBO.GetFirst(j => j.Prefix == "CI");
                }
                else if (data.IdDocType == 2)
                {
                    consecutive = configBO.GetFirst(j => j.Prefix == "CE");
                }

                string number = (++consecutive.Consecutive).ToString();
                number = number.PadLeft((8 - number.Length), '0');

                data.Consecutive = consecutive.Prefix + number;

                docBO.Create(data);
                configBO.Update(consecutive);

                return(StatusCode(StatusCodes.Status201Created, new JsonResponse {
                    Status = StatusCodes.Status201Created, Title = SUCCESFULLY, TraceId = Guid.NewGuid().ToString()
                }));
            }
            catch (Exception e)
            {
                logger.LogInformation("Error: {mess}", e);
                return(StatusCode(StatusCodes.Status500InternalServerError, new JsonResponse
                {
                    Status = StatusCodes.Status500InternalServerError,
                    Title = INTERNAL_ERROR,
                    Errors = new string[] { e.Message },
                    TraceId = Guid.NewGuid().ToString()
                }));
            }
        }