Ejemplo n.º 1
0
        /// <summary>
        /// Creates new entity and saves changings
        /// </summary>
        /// <param name="entity">An instance of new entity</param>
        /// <returns>Returns created entity</returns>
        public virtual T Create(T entity)
        {
            var newEntity = _repository.Add(entity);

            _repository.Commit();
            return(newEntity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates FileInfo from the file
        /// </summary>
        /// <param name="file">The file that being saved</param>
        /// <param name="newFileName">The New File Name for the file</param>
        /// <param name="userId">Id of the user</param>
        /// <returns></returns>
        public bool CreateFileInfo(IFormFile file, string newFileName, int userId)
        {
            string   ext      = System.IO.Path.GetExtension(file.FileName).ToLowerInvariant();
            FileInfo fileInfo = new FileInfo
            {
                FileName      = file.FileName,
                FileSize      = file.Length,
                FileExtension = ext.Replace(".", ""),
                NewFileName   = newFileName,
                UploadDate    = DateTime.Now,
                UserId        = userId
            };

            _repository.Add(fileInfo);
            return(_repository.Commit());
        }