Пример #1
0
        public async Task <Result> CreateAsync(CastMemberDataModel dataModel)
        {
            if (!string.IsNullOrWhiteSpace(dataModel.CastId))
            {
                return(new Result(false, "CastId should not be provided during creation"));
            }

            dataModel.CastId   = Convert.ToString(Guid.NewGuid());
            dataModel.CreateAt = DateTime.UtcNow;

            await collection.InsertOneAsync(dataModel);

            return(new Result(true)
            {
                Data = dataModel
            });
        }
Пример #2
0
        public async Task <IActionResult> AddNewAsync([FromBody] CastMemberDataModel dataModel)
        {
            var result = await repository.CreateAsync(dataModel);

            return(result.Ok ? (IActionResult)Ok(result) : BadRequest(result.Message));
        }