Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromHeader] Guid userId, [FromBody] CreateClinicCommand command)
        {
            var clinicId = await clinicLogic.SaveClinic(command);

            if (clinicId == Guid.Empty)
            {
                return(BadRequest());
            }

            return(CreatedAtAction(nameof(GetClinic), new { id = clinicId }, clinicId));
        }
Ejemplo n.º 2
0
        public async Task <Guid> SaveClinic(CreateClinicCommand command)
        {
            var clinic = mapper.Map <Entities.Clinic>(command);

            clinic.Id        = Guid.NewGuid();
            clinic.IsActive  = true;
            clinic.Created   = DateTime.UtcNow;
            clinic.CreatedBy = command.CreatedBy;
            clinic.Updated   = DateTime.UtcNow;
            clinic.UpdatedBy = command.CreatedBy;

            await context.Clinic.AddAsync(clinic);

            var rowChanged = await context.SaveChangesAsync();

            if (rowChanged == 0)
            {
                return(Guid.Empty);
            }

            return(clinic.Id);
        }