public Manager(ManagerCreateCommand command) { Login = command.Login; Password = command.Password; Phone = command.Phone; typeManager = command.typeManager; ColorPen = command.ColorPen.ToString(); }
public async Task <IActionResult> Post([FromBody] ManagerCreateCommand command) { var manager = await _context.Set <Data.Entities.Users.Manager>() .AddAsync(new Data.Entities.Users.Manager(command)); await _context.SaveChangesAsync(); var result = new ManagerDto() { Id = manager.Entity.Id, Login = manager.Entity.Login, Password = manager.Entity.Password, Phone = manager.Entity.Phone, WorkgroupId = _context.Set <WorkGroup>().FirstOrDefault(x => x.EscortManagerId == manager.Entity.Id || x.RegionalManagerId == manager.Entity.Id)?.Id, WorkgroupTitle = _context.Set <WorkGroup>().FirstOrDefault(x => x.EscortManagerId == manager.Entity.Id || x.RegionalManagerId == manager.Entity.Id)?.Title, TypeManager = manager.Entity.typeManager == Data.Enums.TypeManager.Manager ? 2 : manager.Entity.typeManager == Data.Enums.TypeManager.Marketolog ? 3 : manager.Entity.typeManager == Data.Enums.TypeManager.Call_Checker ? 4 : 5, ColorPen = manager.Entity.ColorPen != null?Convert.ToInt32(manager.Entity.ColorPen) : 0 }; return(Ok(result)); }