示例#1
0
        public async Task <IActionResult> Insert(DirectorInsertDto directorInsertDto)
        {
            directorInsertDto.CreatedByUserName  = "******";
            directorInsertDto.ModifiedByUserName = "******";
            directorInsertDto.PicturePath        = await ImageExtensions.ImageUpload(
                directorInsertDto.FirstName + directorInsertDto.LastName,
                "directors", directorInsertDto.Picture, _env);

            var insertedDirector = await _directorService.Insert(directorInsertDto);

            if (insertedDirector.ResultStatus == ResultStatus.Success)
            {
                return(Json(0));
            }
            return(Json(1));
        }
        public async Task <IDataResult <Director> > Insert(DirectorInsertDto directorInsertDto)
        {
            var director = _mapper.Map <Director>(directorInsertDto);

            director.ModifiedDate = director.CreatedDate;

            var insertedDirector = await _unitOfWork.Directors.InsertAsync(director);

            await _unitOfWork.SaveAsync();

            if (insertedDirector != null)
            {
                return(new DataResult <Director>(ResultStatus.Success, insertedDirector));
            }

            return(new DataResult <Director>(ResultStatus.Error, null));
        }